|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.click.control.AbstractControl net.sf.click.control.AbstractContainer
Provides a default implementation of the Container
interface,
to make it easier for developers to implement their own containers.
AbstractControl.getTag()
to return a specific HTML element.
The following example shows how to create an HTML div element:
public class Div extends AbstractContainer { public String getTag() { // Return the HTML tag return "div"; } }
Field Summary | |
protected Map |
controlMap
The map of controls keyed by field name. |
protected List |
controls
The list of 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 | |
AbstractContainer()
Create a container with no name defined. |
|
AbstractContainer(String name)
Create a container with the given name. |
Method Summary | |
Control |
add(Control control)
Add the control to the container and return the added instance. |
boolean |
contains(Control control)
Return true if the container contains the specified control. |
Control |
getControl(String controlName)
Return the named control from the container if found or null otherwise. |
Map |
getControlMap()
Return the map of controls where each map's key / value pair will consist of the control name and instance. |
List |
getControls()
Return the sequential list of controls held by the container. |
int |
getControlSizeEst()
Return the estimated rendered control size in characters. |
String |
getHtmlImports()
Return the HTML import string to be include in the page. |
boolean |
hasControls()
Returns true if this container has existing controls, false otherwise. |
Control |
insert(Control control,
int index)
Add the control to the container at the specified index, and return the added instance. |
void |
onDestroy()
The on destroy request event handler. |
void |
onInit()
The on initialize event handler. |
boolean |
onProcess()
The on process event handler. |
void |
onRender()
The on render event handler. |
boolean |
remove(Control control)
Remove the given control from the container, returning true if the control was found in the container and removed, or false if the control was not found. |
void |
render(HtmlStringBuffer buffer)
Render the HTML representation of the container and all its child controls to the specified buffer. |
protected void |
renderChildren(HtmlStringBuffer buffer)
Render this container children to the specified buffer. |
protected void |
renderContent(HtmlStringBuffer buffer)
Render this container content to the specified buffer. |
protected void |
renderTagEnd(String tagName,
HtmlStringBuffer buffer)
Closes the specifies tag. |
String |
toString()
Returns the HTML representation of this control. |
Methods inherited from class net.sf.click.control.AbstractControl |
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getId, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, getTag, hasAttribute, hasAttributes, hasStyles, onDeploy, registerActionEvent, removeStyleClass, renderTagBegin, setActionListener, setAttribute, setId, 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 net.sf.click.Control |
getContext, getId, getMessages, getName, getParent, onDeploy, setListener, setName, setParent |
Field Detail |
protected List controls
protected Map controlMap
Constructor Detail |
public AbstractContainer()
public AbstractContainer(String name)
name
- the container nameMethod Detail |
public Control add(Control control)
Container
add
in interface Container
control
- 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 Control insert(Control control, int index)
insert
in interface Container
control
- the control to add to the containerindex
- the index at which the control is to be inserted
IllegalArgumentException
- if the control is null or if the control
and container is the same instance or the container already contains
a control with the same name or if a Field name is not defined
IndexOutOfBoundsException
- if index is out of range
(index < 0 || index > getControls().size())Container.insert(net.sf.click.Control, int)
public boolean remove(Control control)
Container
remove
in interface Container
control
- the control to remove from the container
IllegalArgumentException
- if the control is nullContainer.remove(net.sf.click.Control).
public List getControls()
Container
getControls
in interface Container
Container.getControls().
public Control getControl(String controlName)
Container
getControl
in interface Container
controlName
- the name of the control to get from the container
Container.getControl(java.lang.String)
public boolean contains(Control control)
Container
contains
in interface Container
control
- the control whose presence in this container is to be tested
Container.contains(net.sf.click.Control)
public boolean hasControls()
hasControls
in interface Container
public Map getControlMap()
AbstractControl.name
,
will not be included in the returned map.
public int getControlSizeEst()
AbstractControl
getControlSizeEst
in class AbstractControl
AbstractControl.getControlSizeEst().
public boolean onProcess()
Control
Container
implementations should recursively
invoke the onProcess method on each of their child controls ensuring that
all controls receive this event. However when a control onProcess method
return false, no other controls onProcess method should be invoked.
When a control is processed it should return true if the Page should
continue event processing, or false if no other controls should be
processed and the Page.onGet()
or Page.onPost()
methods
should not be invoked.
Please note: a common problem when overriding onProcess in
subclasses is forgetting to call super.onProcess(). Consider
carefully whether you should call super.onProcess() or not,
especially for Container
s which by default
call onProcess on all their child controls as well.
onProcess
in interface Control
onProcess
in class AbstractControl
Control.onProcess().
public void onDestroy()
Control
Container
implementations should recursively
invoke the onDestroy method on each of their child controls ensuring that
all controls receive this event.
Please note: a common problem when overriding onDestroy in
subclasses is forgetting to call super.onDestroy(). Consider
carefully whether you should call super.onDestroy() or not,
especially for Container
s which by default
call onDestroy on all their child controls as well.
onDestroy
in interface Control
onDestroy
in class AbstractControl
Control.onDestroy()
public void onInit()
Control
Control.onProcess()
method is called.
Container
implementations should recursively
invoke the onInit method on each of their child controls ensuring that
all controls receive this event.
Please note: a common problem when overriding onInit in
subclasses is forgetting to call super.onInit(). Consider
carefully whether you should call super.onInit() or not,
especially for Container
s which by default
call onInit on all their child controls as well.
onInit
in interface Control
onInit
in class AbstractControl
Control.onInit()
public void onRender()
Control
Container
implementations should recursively
invoke the onRender method on each of their child controls ensuring that
all controls receive this event.
Please note: a common problem when overriding onRender in
subclasses is forgetting to call super.onRender(). Consider
carefully whether you should call super.onRender() or not,
especially for Container
s which by default
call onRender on all their child controls as well.
onRender
in interface Control
onRender
in class AbstractControl
Control.onRender()
public String getHtmlImports()
Control
protected static final String HTML_IMPORT = "<script type=\"text/javascript\" src=\"{0}/click/custom.js\"></script>"; public String getHtmlImports() { return ClickUtils.createHtmlImport(HTML_IMPORTS, getResourceVersionIndicator(), getContext()); }Note multiple import lines should be separated by a '\n' char, as the
PageImports
will
parse multiple import lines on the '\n' char and ensure that
imports are not included twice.
The order in which JS and CSS files are include will be preserved in the
page.
Also note: a common problem when overriding getHtmlImports in
subclasses is forgetting to call super.getHtmlImports. Consider
carefully whether you should call super.getHtmlImports or not.
getHtmlImports
in interface Control
getHtmlImports
in class AbstractControl
Control.getHtmlImports()
public void render(HtmlStringBuffer buffer)
AbstractControl.getTag()
returns null, this method will render only its
child controls.
render
in interface Control
render
in class AbstractControl
buffer
- the specified buffer to render the control's output toAbstractControl.render(net.sf.click.util.HtmlStringBuffer)
public String toString()
render(net.sf.click.util.HtmlStringBuffer)
. The size of buffer
is determined by getControlSizeEst()
.
toString
in class AbstractControl
Object.toString()
protected void renderTagEnd(String tagName, HtmlStringBuffer buffer)
AbstractControl
renderTagEnd
in class AbstractControl
tagName
- the name of the tag to closebuffer
- the buffer to append the output toAbstractControl.renderTagEnd(java.lang.String, net.sf.click.util.HtmlStringBuffer).
protected void renderContent(HtmlStringBuffer buffer)
buffer
- the buffer to append the output toprotected void renderChildren(HtmlStringBuffer buffer)
buffer
- the buffer to append the output togetControls()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |