|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.click.control.AbstractControl
net.sf.click.control.AbstractContainer
net.sf.click.control.Panel
Provides a Panel control for creating customized layout sections within a page.
template and model.
This allows you to create very modular components. For example, if you add
a tab control to your Page, each tab could refer to a separate Panel.
Each Panel template could then render its own Form or Table
controls.
<fieldset> <legend class="title"> $messages.heading </legend> $messages.content </fieldset>Then in our page class we would include the Panel. With the $messages.heading and $messages.content values defined in the Pages properties file.
public class WelcomePage extends Page { public Panel panel = new Panel("panel", "/panel-template.htm"); }In our WelcomePage template welcome.htm would simply reference our panel control:
$panel
The Panel template would then be merged with the template model and rendered
in the page as:
Panel rendering is performed using the AbstractContainer.toString() method, and the
template model is created using createTemplateModel().
Format object for formatting the display of objectsSessionMap adaptor for the users HttpSession
| Field Summary | |
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 |
model
A temporary storage for model objects until the Page is set. |
protected List |
panels
The list of sub panels. |
protected String |
template
The path of the template to render. |
| Fields inherited from class net.sf.click.control.AbstractContainer |
controlMap, controls |
| Fields inherited from class net.sf.click.control.AbstractControl |
actionListener, attributes, listener, listenerMethod, messages, name, parent, styles |
| Fields inherited from interface net.sf.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 |
add(Control control)
Add the control to the panel and return the specified control. |
Control |
addControl(Control control)
|
void |
addModel(String name,
Object value)
Add the named object value to the Panels model map. |
protected Map |
createTemplateModel()
Create a model to merge with the template. |
String |
getId()
Return the panel id value. |
String |
getLabel()
Return the panel display label. |
Map |
getModel()
Return the panels model map. |
List |
getPanels()
Return the list of sub panels associated with this panel. |
String |
getTemplate()
Return the path of the template to render. |
boolean |
isDisabled()
Return true if the panel is disabled. |
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)
|
void |
render(HtmlStringBuffer buffer)
Render the HTML string representation of the Panel. |
void |
setActionListener(ActionListener listener)
This method does nothing, since Panel does not support action listener callback. |
void |
setDisabled(boolean disabled)
Set whether the panel is disabled. |
void |
setId(String id)
Set the id for this panel. |
void |
setLabel(String label)
Set the Panel display caption. |
void |
setListener(Object listener,
String method)
This method does nothing, since Panel does not support listener callback. |
void |
setTemplate(String template)
Set the path of the template to render. |
| Methods inherited from class net.sf.click.control.AbstractContainer |
contains, getControl, getControlMap, getControls, getControlSizeEst, getHtmlImports, hasControls, insert, onDestroy, onInit, onProcess, onRender, renderChildren, renderContent, renderTagEnd, toString |
| Methods inherited from class net.sf.click.control.AbstractControl |
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, getTag, hasAttribute, hasAttributes, hasStyles, onDeploy, registerActionEvent, removeStyleClass, renderTagBegin, setAttribute, setName, setParent, setStyle |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface net.sf.click.Control |
getContext, getMessages, getName, getParent, onDeploy, setName, setParent |
| Field Detail |
protected boolean disabled
protected String id
protected String label
protected Map model
protected List panels
protected String template
| 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 paneltemplate - the template pathid - the id HTML attribute valuepublic Panel()
| Method Detail |
public Control addControl(Control control)
control - the control to add to the container
IllegalArgumentException - if the control is null, if the name
of the control is not defined or the container already contains a
control with the same nameadd(net.sf.click.Control)public Control add(Control control)
Container.add(net.sf.click.Control), note
the following:
getModel(). This allows
one to reference the control in the Panels template.
getPanels().
add in interface Containeradd in class AbstractContainercontrol - the control to add to the container
IllegalArgumentException - if the control is null or the container
already contains a control with the same nameContainer.add(net.sf.click.Control)public boolean removeControl(Control control)
control - the control to remove from the container
IllegalArgumentException - if the control is null or if the name of
the control is not definedremove(net.sf.click.Control)public boolean remove(Control control)
Container.remove(net.sf.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(net.sf.click.Control)public boolean isDisabled()
public void setDisabled(boolean disabled)
disabled - the disabled flagpublic String getId()
getId in interface ControlgetId in class AbstractControlControl.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 setListener(Object listener,
String method)
setListener in interface ControlsetListener in class AbstractControllistener - the listener object with the named method to invokemethod - the name of the method to invokeControl.setListener(Object, String)public void setActionListener(ActionListener listener)
setActionListener in class AbstractControllistener - the control's action listenerAbstractControl.setActionListener(net.sf.click.ActionListener)
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
null, or if there is already a named value in the modelpublic Map getModel()
public List getPanels()
add(Control) instead.
public String getTemplate()
public void setTemplate(String template)
template - the path of the template to renderpublic 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 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 | |||||||||