Class AbstractContainer
- java.lang.Object
-
- org.openidentityplatform.openam.click.control.AbstractControl
-
- org.openidentityplatform.openam.click.control.AbstractContainer
-
- All Implemented Interfaces:
Serializable,org.openidentityplatform.openam.click.Control,Container
- Direct Known Subclasses:
Form
public abstract class AbstractContainer extends AbstractControl implements Container
Provides a default implementation of theContainerinterface to make it easier for developers to create their own containers.Subclasses can override
AbstractControl.getTag()to return a specific HTML element.The following example shows how to create an HTML
divelement:public class Div extends AbstractContainer { public String getTag() { // Return the HTML tag return "div"; } }- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,org.openidentityplatform.openam.click.Control>controlMapThe map of controls keyed by field name.protected List<org.openidentityplatform.openam.click.Control>controlsThe list of controls.-
Fields inherited from class org.openidentityplatform.openam.click.control.AbstractControl
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles
-
-
Constructor Summary
Constructors Constructor Description AbstractContainer()Create a container with no name defined.AbstractContainer(String name)Create a container with the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description org.openidentityplatform.openam.click.Controladd(org.openidentityplatform.openam.click.Control control)Adds the given control to the container and returns it.booleancontains(org.openidentityplatform.openam.click.Control control)Return true if the container contains the specified control.org.openidentityplatform.openam.click.ControlgetControl(String controlName)Return the named control from the container if found or null otherwise.Map<String,org.openidentityplatform.openam.click.Control>getControlMap()Return the map of controls where each map's key / value pair will consist of the control name and instance.List<org.openidentityplatform.openam.click.Control>getControls()Return the sequential list of controls held by the container.intgetControlSizeEst()Return the estimated rendered control size in characters.booleanhasControls()Returns true if this container has existing controls, false otherwise.org.openidentityplatform.openam.click.Controlinsert(org.openidentityplatform.openam.click.Control control, int index)Add the control to the container at the specified index, and return the added instance.voidonDestroy()This method does nothing.voidonInit()This method does nothing.booleanonProcess()The on process event handler.voidonRender()This method does nothing.booleanremove(org.openidentityplatform.openam.click.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.voidrender(HtmlStringBuffer buffer)Render the HTML representation of the container and all its child controls to the specified buffer.protected voidrenderChildren(HtmlStringBuffer buffer)Render this container children to the specified buffer.protected voidrenderContent(HtmlStringBuffer buffer)Render this container content to the specified buffer.protected voidrenderTagEnd(String tagName, HtmlStringBuffer buffer)Closes the specified tag.org.openidentityplatform.openam.click.Controlreplace(org.openidentityplatform.openam.click.Control currentControl, org.openidentityplatform.openam.click.Control newControl)Deprecated.this method was used for stateful pages, which have been deprecatedStringtoString()Returns the HTML representation of this control.-
Methods inherited from class org.openidentityplatform.openam.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
-
-
-
-
Constructor Detail
-
AbstractContainer
public AbstractContainer()
Create a container with no name defined.
-
AbstractContainer
public AbstractContainer(String name)
Create a container with the given name.- Parameters:
name- the container name
-
-
Method Detail
-
add
public org.openidentityplatform.openam.click.Control add(org.openidentityplatform.openam.click.Control control)
Adds the given control to the container and returns it.Please note: if the container contains a control with the same name as the given control, that control will be
replacedby the given control. If a control has no name defined it cannot be replaced.- Specified by:
addin interfaceContainer- Parameters:
control- the control to add to the container- Returns:
- the control that was added to the container
- Throws:
IllegalArgumentException- if the control is null- See Also:
Container.add(Control)
-
insert
public org.openidentityplatform.openam.click.Control insert(org.openidentityplatform.openam.click.Control control, int index)Add the control to the container at the specified index, and return the added instance.Please note: if the container contains a control with the same name as the given control, that control will be
replacedby 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.
- Specified by:
insertin interfaceContainer- Parameters:
control- the control to add to the containerindex- the index at which the control is to be inserted- Returns:
- the control that was added to the container
- Throws:
IllegalArgumentException- if the control is null or if the control and container is the same instanceIndexOutOfBoundsException- if index is out of range(index < 0 || index > getControls().size())- See Also:
Container.insert(Control, int)
-
remove
public boolean remove(org.openidentityplatform.openam.click.Control control)
Description copied from interface:ContainerRemove 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.- Specified by:
removein interfaceContainer- Parameters:
control- the control to remove from the container- Returns:
- true if the control was removed from the container
- Throws:
IllegalArgumentException- if the control is null- See Also:
Container.remove(Control)
-
replace
public org.openidentityplatform.openam.click.Control replace(org.openidentityplatform.openam.click.Control currentControl, org.openidentityplatform.openam.click.Control newControl)Deprecated.this method was used for stateful pages, which have been deprecatedReplace the control in the container at the specified index, and return the newly added control.- Specified by:
replacein interfaceContainer- Parameters:
currentControl- the control currently contained in the containernewControl- the control to replace the current control contained in the container- Returns:
- the new control that replaced the current control
- Throws:
IllegalArgumentException- if the currentControl or newControl is nullIllegalStateException- if the currentControl is not contained in the container- See Also:
Container.replace(Control, Control)
-
getControls
public List<org.openidentityplatform.openam.click.Control> getControls()
Description copied from interface:ContainerReturn the sequential list of controls held by the container.- Specified by:
getControlsin interfaceContainer- Returns:
- the sequential list of controls held by the container
- See Also:
Container.getControls()
-
getControl
public org.openidentityplatform.openam.click.Control getControl(String controlName)
Description copied from interface:ContainerReturn the named control from the container if found or null otherwise.- Specified by:
getControlin interfaceContainer- Parameters:
controlName- the name of the control to get from the container- Returns:
- the named control from the container if found or null otherwise
- See Also:
Container.getControl(String)
-
contains
public boolean contains(org.openidentityplatform.openam.click.Control control)
Description copied from interface:ContainerReturn true if the container contains the specified control.- Specified by:
containsin interfaceContainer- Parameters:
control- the control whose presence in this container is to be tested- Returns:
- true if the container contains the specified control
- See Also:
Container.contains(Control)
-
hasControls
public boolean hasControls()
Returns true if this container has existing controls, false otherwise.- Specified by:
hasControlsin interfaceContainer- Returns:
- true if the container has existing controls, false otherwise.
-
getControlMap
public Map<String,org.openidentityplatform.openam.click.Control> getControlMap()
Return the map of controls where each map's key / value pair will consist of the control name and instance.Controls added to the container that did not specify a
AbstractControl.name, will not be included in the returned map.- Returns:
- the map of controls
-
getControlSizeEst
public int getControlSizeEst()
Description copied from class:AbstractControlReturn the estimated rendered control size in characters.- Overrides:
getControlSizeEstin classAbstractControl- Returns:
- the estimated rendered control size in characters
- See Also:
AbstractControl.getControlSizeEst()
-
onProcess
public boolean onProcess()
Description copied from interface:org.openidentityplatform.openam.click.ControlThe on process event handler. Each control will be processed when the Page is requested.ClickServlet will process all Page controls in the order they were added to the Page.
Containerimplementations 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()orPage.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.- Specified by:
onProcessin interfaceorg.openidentityplatform.openam.click.Control- Overrides:
onProcessin classAbstractControl- Returns:
- true to continue Page event processing or false otherwise
- See Also:
Control.onProcess()
-
onDestroy
public void onDestroy()
Description copied from class:AbstractControlThis method does nothing. Subclasses may override this method to perform clean up any resources.- Specified by:
onDestroyin interfaceorg.openidentityplatform.openam.click.Control- Overrides:
onDestroyin classAbstractControl- See Also:
Control.onDestroy()
-
onInit
public void onInit()
Description copied from class:AbstractControlThis method does nothing. Subclasses may override this method to perform initialization.- Specified by:
onInitin interfaceorg.openidentityplatform.openam.click.Control- Overrides:
onInitin classAbstractControl- See Also:
Control.onInit()
-
onRender
public void onRender()
Description copied from class:AbstractControlThis method does nothing. Subclasses may override this method to perform pre rendering logic.- Specified by:
onRenderin interfaceorg.openidentityplatform.openam.click.Control- Overrides:
onRenderin classAbstractControl- See Also:
Control.onRender()
-
render
public void render(HtmlStringBuffer buffer)
Render the HTML representation of the container and all its child controls to the specified buffer.If
AbstractControl.getTag()returns null, this method will render only its child controls.- Specified by:
renderin interfaceorg.openidentityplatform.openam.click.Control- Overrides:
renderin classAbstractControl- Parameters:
buffer- the specified buffer to render the control's output to- See Also:
AbstractControl.render(HtmlStringBuffer)
-
toString
public String toString()
Returns the HTML representation of this control.This method delegates the rendering to the method
render(HtmlStringBuffer). The size of buffer is determined bygetControlSizeEst().- Overrides:
toStringin classAbstractControl- Returns:
- the HTML representation of this control
- See Also:
Object.toString()
-
renderTagEnd
protected void renderTagEnd(String tagName, HtmlStringBuffer buffer)
Description copied from class:AbstractControlCloses the specified tag.- Overrides:
renderTagEndin classAbstractControl- Parameters:
tagName- the name of the tag to closebuffer- the buffer to append the output to- See Also:
AbstractControl.renderTagEnd(String, HtmlStringBuffer)
-
renderContent
protected void renderContent(HtmlStringBuffer buffer)
Render this container content to the specified buffer.- Parameters:
buffer- the buffer to append the output to
-
renderChildren
protected void renderChildren(HtmlStringBuffer buffer)
Render this container children to the specified buffer.- Parameters:
buffer- the buffer to append the output to- See Also:
getControls()
-
-