Class 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 the Container interface 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 div element:

     public class Div extends AbstractContainer {
    
         public String getTag() {
             // Return the HTML tag
             return "div";
         }
     } 
    See Also:
    Serialized Form
    • Field Detail

      • controls

        protected List<org.openidentityplatform.openam.click.Control> controls
        The list of controls.
      • controlMap

        protected Map<String,​org.openidentityplatform.openam.click.Control> controlMap
        The map of controls keyed by field name.
    • 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 replaced by the given control. If a control has no name defined it cannot be replaced.

        Specified by:
        add in interface Container
        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 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.

        Specified by:
        insert in interface Container
        Parameters:
        control - the control to add to the container
        index - 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 instance
        IndexOutOfBoundsException - 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: Container
        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.
        Specified by:
        remove in interface Container
        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 deprecated
        Replace the control in the container at the specified index, and return the newly added control.
        Specified by:
        replace in interface Container
        Parameters:
        currentControl - the control currently contained in the container
        newControl - 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 null
        IllegalStateException - 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: Container
        Return the sequential list of controls held by the container.
        Specified by:
        getControls in interface Container
        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: Container
        Return the named control from the container if found or null otherwise.
        Specified by:
        getControl in interface Container
        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: Container
        Return true if the container contains the specified control.
        Specified by:
        contains in interface Container
        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:
        hasControls in interface Container
        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
      • onProcess

        public boolean onProcess()
        Description copied from interface: org.openidentityplatform.openam.click.Control
        The 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.

        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 Containers which by default call onProcess on all their child controls as well.

        Specified by:
        onProcess in interface org.openidentityplatform.openam.click.Control
        Overrides:
        onProcess in class AbstractControl
        Returns:
        true to continue Page event processing or false otherwise
        See Also:
        Control.onProcess()
      • onDestroy

        public void onDestroy()
        Description copied from class: AbstractControl
        This method does nothing. Subclasses may override this method to perform clean up any resources.
        Specified by:
        onDestroy in interface org.openidentityplatform.openam.click.Control
        Overrides:
        onDestroy in class AbstractControl
        See Also:
        Control.onDestroy()
      • onInit

        public void onInit()
        Description copied from class: AbstractControl
        This method does nothing. Subclasses may override this method to perform initialization.
        Specified by:
        onInit in interface org.openidentityplatform.openam.click.Control
        Overrides:
        onInit in class AbstractControl
        See Also:
        Control.onInit()
      • onRender

        public void onRender()
        Description copied from class: AbstractControl
        This method does nothing. Subclasses may override this method to perform pre rendering logic.
        Specified by:
        onRender in interface org.openidentityplatform.openam.click.Control
        Overrides:
        onRender in class AbstractControl
        See Also:
        Control.onRender()
      • 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()