|
|||||||||
| 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
public abstract class AbstractContainer
Provides a default implementation of the Container interface
to make it easier for developers to create 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<String,Control> |
controlMap
The map of controls keyed by field name. |
protected List<Control> |
controls
The list of 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 | |
|---|---|
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<String,Control> |
getControlMap()
Return the map of controls where each map's key / value pair will consist of the control name and instance. |
List<Control> |
getControls()
Return the sequential list of controls held by the container. |
int |
getControlSizeEst()
Return the estimated rendered control size in characters. |
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()
This method does nothing. |
void |
onInit()
This method does nothing. |
boolean |
onProcess()
The on process event handler. |
void |
onRender()
This method does nothing. |
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 specified tag. |
Control |
replace(Control currentControl,
Control newControl)
Deprecated. this method was used for stateful pages, which have been deprecated |
String |
toString()
Returns the HTML representation of this control. |
| Methods inherited from class org.apache.click.control.AbstractControl |
|---|
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHeadElements, getHtmlImports, getId, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, getTag, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, removeBehavior, 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 org.apache.click.Control |
|---|
getBehaviors, getContext, getHeadElements, getId, getMessages, getName, getParent, hasBehaviors, isAjaxTarget, onDeploy, setListener, setName, setParent |
| Field Detail |
|---|
protected List<Control> controls
protected Map<String,Control> controlMap
| Constructor Detail |
|---|
public AbstractContainer()
public AbstractContainer(String name)
name - the container name| Method Detail |
|---|
public Control add(Control control)
Container
add in interface Containercontrol - the control to add to the container
IllegalArgumentException - if the control is null
Please note: if the container contains a control with the same name
as the given control, that control will be
{@link #replace(org.apache.click.Control, org.apache.click.Control) replaced}
by the given control. If a control has no name defined it cannot be replaced.
public Control insert(Control control,
int index)
replaced
by the given control. If a control has no name defined it cannot be replaced.
Also note if the specified control already has a parent assigned,
it will automatically be removed from that parent and inserted into this
container.
insert in interface Containercontrol - 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
IndexOutOfBoundsException - if index is out of range
(index < 0 || index > getControls().size())Container.insert(org.apache.click.Control, int)public boolean remove(Control control)
Container
remove in interface Containercontrol - the control to remove from the container
IllegalArgumentException - if the control is nullContainer.remove(org.apache.click.Control).
public Control replace(Control currentControl,
Control newControl)
replace in interface ContainercurrentControl - the control currently contained in the containernewControl - the control to replace the current control contained in
the container
IllegalArgumentException - if the currentControl or newControl is
null
IllegalStateException - if the currentControl is not contained in
the containerContainer.replace(org.apache.click.Control, org.apache.click.Control)public List<Control> getControls()
Container
getControls in interface ContainerContainer.getControls().public Control getControl(String controlName)
Container
getControl in interface ContainercontrolName - the name of the control to get from the container
Container.getControl(java.lang.String)public boolean contains(Control control)
Container
contains in interface Containercontrol - the control whose presence in this container is to be tested
Container.contains(org.apache.click.Control)public boolean hasControls()
hasControls in interface Containerpublic Map<String,Control> getControlMap()
AbstractControl.name,
will not be included in the returned map.
public int getControlSizeEst()
AbstractControl
getControlSizeEst in class AbstractControlAbstractControl.getControlSizeEst().public boolean onProcess()
ControlContainer 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 Containers which by default
call onProcess on all their child controls as well.
onProcess in interface ControlonProcess in class AbstractControlControl.onProcess().public void onDestroy()
AbstractControl
onDestroy in interface ControlonDestroy in class AbstractControlControl.onDestroy()public void onInit()
AbstractControl
onInit in interface ControlonInit in class AbstractControlControl.onInit()public void onRender()
AbstractControl
onRender in interface ControlonRender in class AbstractControlControl.onRender()public void render(HtmlStringBuffer buffer)
AbstractControl.getTag() returns null, this method will render only its
child controls.
render in interface Controlrender in class AbstractControlbuffer - the specified buffer to render the control's output toAbstractControl.render(org.apache.click.util.HtmlStringBuffer)public String toString()
render(org.apache.click.util.HtmlStringBuffer). The size of buffer
is determined by getControlSizeEst().
toString in class AbstractControlObject.toString()
protected void renderTagEnd(String tagName,
HtmlStringBuffer buffer)
AbstractControl
renderTagEnd in class AbstractControltagName - the name of the tag to closebuffer - the buffer to append the output toAbstractControl.renderTagEnd(java.lang.String, org.apache.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 | ||||||||