|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.click.control.AbstractControl
org.apache.click.control.AbstractContainer
org.apache.click.control.Panel
public class Panel
Provides a Panel container that has its own template and
model.
Page model is also made available to the
Panel template.
The time is now $time
Then in our page class, SimplePageDemo, we create and add the Panel
instance:
public class SimplePageDemo extends Page {
private Panel panel = new Panel("panel", "/panel/simple-panel.htm");
public SimplePanelDemo() {
Date time = new Date();
// Add the $time variable to the panel model
panel.getModel().put("time", time);
addControl(panel);
}
}
The SimplePanelDemo template, /simple-panel-demo.htm, would
reference the panel control:
$panel
The Panel template would then be merged with the Panel model and
rendered in the page as:
Time time is now Sun Mar 15 07:32:51 EST 2009
heading=Welcome content=Welcome to MyCorp<p/>MyCorp is your telecommuting office portal. Its just like being there at the office!Then we create the /panel/simple-panel.htm that references the localized Page properties. Since a Page properties are made available through the $messages map, the Panel can access the Page properties using the variables $messages.header and $messages.content:
<fieldset> <legend class="title"> $messages.heading </legend> $messages.content </fieldset>In our page class, SimplePageDemo, we create and add the Panel instance:
public class SimplePanelDemo extends Page {
public Panel panel = new Panel("panel", "/panel/simple-panel.htm");
}
In the Page above we make use of Click's autobinding feature by
declaring a public Panel field. Autobinding will automatically add
the Panel to the Page model.
The SimplePanelDemo template, /simple-panel-demo.htm, would
reference the panel control:
$panel
And the result is:
$form
Next up is the CustomerPanel:
public class CustomerPanel extends Panel {
private Form form = new Form("form");
public CustomerPanel(String name) {
super(name);
// We explicitly set the customer panel template
setTemplate("/panel/customer-panel.htm");
form.add(new TextField("name");
form.add(new DateField("dateJoined");
form.add(new DoubleField("holdings");
}
}
The Border Panel template, /panel/border-panel.htm, will draw a
Border around its contents:
<div> style="border: 1px solid black">
$panel
</div>
Lastly we specify the NestedDemo Page, that creates a Border Panel,
and adds CustomerPanel as a child.
public class NestedDemo extends Page {
private Panel borderPanel = new Panel("borderPanel", "/panel/border-panel.htm");
private CustomerPanel customerPanel = new CustomerPanel("panel");
public void onInit() {
// Add CustomerPanel to the Border panel
parentPanel.add(childPanel);
// Add border panel to page
addControl(parentPanel);
}
}
The Page template, /nested-demo.htm, would reference the
$borderPanel variable:
$borderPanel
createTemplateModel())
which is merged with the template. This model will include the page model
values, plus any Panel defined model values, with the Panel's values overriding
the Page defined values. In addition a number of predefined values are
automatically added to the model. These values include:
Format object for formatting the display of objectsSessionMap adaptor for the users HttpSession
| Field Summary | |
|---|---|
protected boolean |
active
The panel active value, "true" by default. |
protected boolean |
disabled
The panel disabled value. |
protected String |
id
The "identifier" for this panel (CSS id for rendering). |
protected String |
label
The (localized) label of this panel. |
protected Map<String,Object> |
model
A temporary storage for model objects until the Page is set. |
protected List<Panel> |
panels
The list of sub panels. |
protected String |
template
The path of the template to render. |
| Fields inherited from class org.apache.click.control.AbstractContainer |
|---|
controlMap, controls |
| Fields inherited from class org.apache.click.control.AbstractControl |
|---|
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles |
| Fields inherited from interface org.apache.click.Control |
|---|
CONTROL_MESSAGES |
| Constructor Summary | |
|---|---|
Panel()
Create a Panel with no name or template defined. |
|
Panel(String name)
Create a Panel with the given name. |
|
Panel(String name,
String template)
Create a Panel with the given name and template path. |
|
Panel(String name,
String id,
String template)
Create a Panel with the given name, id attribute and template path. |
|
| Method Summary | |
|---|---|
Control |
addControl(Control control)
Deprecated. use AbstractContainer.add(org.apache.click.Control) instead |
void |
addModel(String name,
Object value)
Add the named object value to the Panels model map. |
protected Map<String,Object> |
createTemplateModel()
Create a model to merge with the template. |
String |
getId()
Return the panel id value. |
String |
getLabel()
Return the panel display label. |
Map<String,Object> |
getModel()
Return the panels model map. |
List<Panel> |
getPanels()
Return the list of sub panels associated with this panel. |
String |
getTemplate()
Return the path of the template to render. |
Control |
insert(Control control,
int index)
Add the control to the panel and return the specified control. |
boolean |
isActive()
Return true if the panel is active. |
boolean |
isDisabled()
Return true if the panel is disabled. |
void |
onInit()
Initialize the panel. |
boolean |
onProcess()
This method processes the Panel request returning true to continue processing or false otherwise. |
void |
onRender()
Perform any pre rendering logic and invoke the onRender() method of any child controls. |
boolean |
remove(Control control)
Remove the control from the panel and returning true if the control was found in the container and removed, or false if the control was not found. |
boolean |
removeControl(Control control)
Deprecated. use remove(org.apache.click.Control) instead |
void |
render(HtmlStringBuffer buffer)
Render the HTML string representation of the Panel. |
Control |
replace(Control currentControl,
Control newControl)
Deprecated. this method was used for stateful pages, which have been deprecated |
void |
setActive(boolean active)
Set the panel active flag. |
void |
setDisabled(boolean disabled)
Set the panel disabled flag. |
void |
setId(String id)
Set the id for this panel. |
void |
setLabel(String label)
Set the Panel display caption. |
void |
setTemplate(String template)
Set the path of the template to render. |
| Methods inherited from class org.apache.click.control.AbstractContainer |
|---|
add, contains, getControl, getControlMap, getControls, getControlSizeEst, hasControls, onDestroy, renderChildren, renderContent, renderTagEnd, toString |
| Methods inherited from class org.apache.click.control.AbstractControl |
|---|
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHeadElements, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, getTag, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, removeBehavior, removeStyleClass, renderTagBegin, setActionListener, setAttribute, setListener, setName, setParent, setStyle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.click.Control |
|---|
getBehaviors, getContext, getHeadElements, getMessages, getName, getParent, hasBehaviors, isAjaxTarget, onDeploy, setListener, setName, setParent |
| Field Detail |
|---|
protected boolean disabled
protected String id
protected String label
protected Map<String,Object> model
protected List<Panel> panels
protected String template
protected boolean active
| Constructor Detail |
|---|
public Panel(String name)
name - the name of the panel
public Panel(String name,
String template)
name - the name of the paneltemplate - the template path
public Panel(String name,
String id,
String template)
name - the name of the panelid - the id HTML attribute valuetemplate - the template pathpublic Panel()
| Method Detail |
|---|
public Control addControl(Control control)
AbstractContainer.add(org.apache.click.Control) instead
control - the control to add to the container
IllegalArgumentException - if the control is null or if the name
of the control is not definedAbstractContainer.add(org.apache.click.Control)
public Control insert(Control control,
int index)
replaced
by the given control. If a control has no name defined it cannot be replaced.
In addition to the requirements specified by
Container.add(org.apache.click.Control), note the following:
model using the control name as the key. The control
can be referenced via it's name from the Panel template.
getPanels().
insert in interface Containerinsert in class AbstractContainercontrol - the control to add to the containerindex - the index at which the control is to be inserted
IllegalArgumentException - if the control is nullContainer.add(org.apache.click.Control)
public Control replace(Control currentControl,
Control newControl)
replace in interface Containerreplace in class AbstractContainercurrentControl - the current control container in the panelnewControl - the control to replace the current control
IllegalArgumentException - if the currentControl or newControl is
null
IllegalStateException - if the currentControl is not contained in
the panelContainer.replace(org.apache.click.Control, org.apache.click.Control)public boolean removeControl(Control control)
remove(org.apache.click.Control) instead
control - the control to remove from the container
IllegalArgumentException - if the control is null or if the name of
the control is not definedremove(org.apache.click.Control)public boolean remove(Control control)
Container.remove(org.apache.click.Control), the controls name
must also be set.
remove in interface Containerremove in class AbstractContainercontrol - the control to remove from the container
IllegalArgumentException - if the control is nullContainer.remove(org.apache.click.Control)public boolean isDisabled()
public void setDisabled(boolean disabled)
disabled - the disabled flagpublic boolean isActive()
public void setActive(boolean active)
onInit(), onProcess(), onRender()) processed.
active - the active flagpublic String getId()
getId in interface ControlgetId in class AbstractControlsetActive(boolean),
Control.getId()public void setId(String id)
setId in class AbstractControlid - the id attribute for this panelpublic String getLabel()
getName() + ".label"If not found then the message will be looked up in the /click-control.properties file using the same key. If a value still cannot be found then the Panel name will be converted into a label using the method:
ClickUtils.toLabel(String)
Typically the label property is used as a header for a particular panel.
For example:
<div id="$panel.id">
<h1>$panel.label</h1>
## content here
</div>
public void setLabel(String label)
label - the display label of the Panel
public void addModel(String name,
Object value)
name - the key name of the object to addvalue - the object to add
IllegalArgumentException - if the name or value parameters are
nullpublic Map<String,Object> getModel()
public List<Panel> getPanels()
AbstractContainer.add(Control) instead.
public String getTemplate()
public void setTemplate(String template)
template - the path of the template to renderpublic void onInit()
inactive panels are not
initialized.
onInit in interface ControlonInit in class AbstractContainerControl.onInit()public boolean onProcess()
Disabled and
inactive panels are not processed.
onProcess in interface ControlonProcess in class AbstractContainerControl.onProcess().public void onRender()
inactive panels are not rendered.
onRender in interface ControlonRender in class AbstractContainerControl.onRender()public void render(HtmlStringBuffer buffer)
template with the template
model. The template model is created using createTemplateModel().
If a Panel template is not defined, a template based on the classes
name will be loaded. For more details please see Context.renderTemplate(Class, Map).
render in interface Controlrender in class AbstractContainerbuffer - the specified buffer to render the control's output toAbstractContainer.toString()protected Map<String,Object> createTemplateModel()
Format object for formatting the display of objectsSessionMap adaptor for the users HttpSession
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||