org.apache.cocoon.forms.formmodel
Class AbstractContainerWidget

java.lang.Object
  extended by org.apache.cocoon.forms.formmodel.AbstractWidget
      extended by org.apache.cocoon.forms.formmodel.AbstractContainerWidget
All Implemented Interfaces:
ContainerWidget, Widget, Locatable
Direct Known Subclasses:
Form, Group, Repeater.RepeaterRow, Union

public abstract class AbstractContainerWidget
extends AbstractWidget
implements ContainerWidget

A general-purpose abstract Widget which can hold zero or more widgets.

Version:
$Id: AbstractContainerWidget.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Field Summary
protected  ValidationError validationError
          validation errors on container widgets
protected  WidgetList widgets
          List of contained widgets.
 
Fields inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget
wasValid
 
Fields inherited from interface org.apache.cocoon.forms.formmodel.Widget
PATH_SEPARATOR
 
Constructor Summary
AbstractContainerWidget(AbstractContainerDefinition definition)
          Constructs AbstractContainerWidget
 
Method Summary
 void addChild(Widget widget)
          Adds a child widget.
 void generateItemSaxFragment(ContentHandler contentHandler, Locale locale)
          Subclass container widgets can call this super.generateItemSaxFragment(..)
 Widget getChild(String id)
          Concrete widgets that contain actual child widgets should override to return the actual child-widget.
 Iterator getChildren()
           
 int getSize()
           
 boolean hasChild(String id)
          Checks if there is a child widget with the given id.
 void initialize()
          Called after widget's environment has been setup, to allow for any contextual initalization such as looking up case widgets for union widgets.
 void readFromRequest(FormContext formContext)
          Delegates the readFromRequest() down to the contained child-widgets.
 boolean validate()
          Delegates the validate() down to the contained child-widgets, and validates the extra rules on this containment level regardless of children widget's validities.
 
Methods inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget
addValidator, broadcastEvent, generateDisplayData, generateLabel, generateSaxFragment, getAttribute, getCombinedState, getDefinition, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getValue, getWidget, getXMLElementAttributes, getXMLElementName, isRequired, isValid, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState, setValue, toString, widgetNameChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.forms.formmodel.Widget
addValidator, broadcastEvent, generateLabel, generateSaxFragment, getAttribute, getCombinedState, getDefinition, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getValue, getWidget, isRequired, isValid, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState, setValue
 

Field Detail

widgets

protected WidgetList widgets
List of contained widgets.


validationError

protected ValidationError validationError
validation errors on container widgets

Constructor Detail

AbstractContainerWidget

public AbstractContainerWidget(AbstractContainerDefinition definition)
Constructs AbstractContainerWidget

Method Detail

initialize

public void initialize()
Called after widget's environment has been setup, to allow for any contextual initalization such as looking up case widgets for union widgets.

Specified by:
initialize in interface Widget
Overrides:
initialize in class AbstractWidget

addChild

public void addChild(Widget widget)
Description copied from interface: ContainerWidget
Adds a child widget.

Specified by:
addChild in interface ContainerWidget

hasChild

public boolean hasChild(String id)
Description copied from interface: ContainerWidget
Checks if there is a child widget with the given id.

Specified by:
hasChild in interface ContainerWidget

getChild

public Widget getChild(String id)
Description copied from class: AbstractWidget
Concrete widgets that contain actual child widgets should override to return the actual child-widget.

Specified by:
getChild in interface ContainerWidget
Overrides:
getChild in class AbstractWidget
Parameters:
id - of the child-widget
Returns:
null if not overriden.

getChildren

public Iterator getChildren()
Specified by:
getChildren in interface ContainerWidget
Returns:
an iterator over the widgets this object contains

getSize

public int getSize()

readFromRequest

public void readFromRequest(FormContext formContext)
Delegates the readFromRequest() down to the contained child-widgets. When overriding one should call super.readFromRequest() to allow child-widgets to process the request. Overide only to add possible request-reading statements on the containment level.

Specified by:
readFromRequest in interface Widget
Parameters:
formContext - to be passed to the Widget.readFromRequest(FormContext) of the contained widgets.

validate

public boolean validate()
Delegates the validate() down to the contained child-widgets, and validates the extra rules on this containment level regardless of children widget's validities.

When overriding one should call super.validate() as the first statement to keep in sync with this behaviour.

Specified by:
validate in interface Widget
Overrides:
validate in class AbstractWidget
Returns:
true only if all contained widgets are valid and the extra validation rules on this containment level are ok.
See Also:
Widget.validate()

generateItemSaxFragment

public void generateItemSaxFragment(ContentHandler contentHandler,
                                    Locale locale)
                             throws SAXException
Subclass container widgets can call this super.generateItemSaxFragment(..) to just insert the child-widget content wrapped in a @lt;fi:widgets@gt;

Overrides:
generateItemSaxFragment in class AbstractWidget
Parameters:
contentHandler - where the SAX is sent to via Widget.generateSaxFragment(ContentHandler, Locale)
locale -
Throws:
SAXException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.