org.riotfamily.forms
Class CompositeElement

java.lang.Object
  extended by org.riotfamily.forms.AbstractElement
      extended by org.riotfamily.forms.AbstractEditorBase
          extended by org.riotfamily.forms.CompositeElement
All Implemented Interfaces:
Element, BeanFactoryAware
Direct Known Subclasses:
AbstractFileUpload, Container, PagePropertiesEditor, SitePropertiesEditor, TemplateElement

public abstract class CompositeElement
extends AbstractEditorBase
implements BeanFactoryAware

Abstract superclass for elements that consist of several child elements. Calls to processRequest() and render() are automatically delegated to the components. Additionally the components are initialized, i.e. setParent(), setForm() and Form.registerElement() are called.


Field Summary
 
Fields inherited from class org.riotfamily.forms.AbstractElement
log
 
Constructor Summary
CompositeElement()
          Empty default constructor.
CompositeElement(List<? extends Element> components)
          Empty default constructor.
 
Method Summary
protected  void addComponent(Element element)
          Adds the given element to the list of components.
protected  void afterFormSet()
          Invokes initComponent(Element) on all components and finally calls initCompositeElement().
 void focus()
          Delegates the call to the first component.
protected  List<Element> getComponents()
           
protected  void initComponent(Element element)
          Sets a reference to the form and registers the element by calling Form.registerElement(Element).
protected  void initCompositeElement()
          Subclasses may override this method to perform initialization tasks.
 boolean isCompositeElement()
          Helper method to check for composite elements in templates.
 boolean isEmpty()
           
 void processRequest(FormRequest request)
          Calls processRequestInternal() and afterwards processRequestComponents() to process the components.
protected  void processRequestCompontents(FormRequest request)
          Processes the request for all the components
protected  void processRequestInternal(FormRequest request)
          Called before processRequest() is invoked on the contained elements.
protected  void removeComponent(Element element)
          Removes the given component.
protected  void renderInternal(PrintWriter writer)
           
 void setBeanFactory(BeanFactory beanFactory)
           
 
Methods inherited from class org.riotfamily.forms.AbstractEditorBase
addChangeListener, afterBindingSet, fireChangeEvent, getEditorBinding, getFieldName, getHint, getLabel, getParamName, hasListeners, setEditorBinding, setFieldName, setParamName
 
Methods inherited from class org.riotfamily.forms.AbstractElement
afterFormContextSet, getEventTriggerId, getForm, getFormContext, getFormListener, getId, getParent, getStyleClass, getSystemStyleClass, getWrapperStyleClass, isEnabled, isRequired, isVisible, render, render, setEnabled, setForm, setFormContext, setHint, setId, setInline, setLabel, setParent, setReadOnly, setRequired, setStyleClass, setVisible, setWrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeElement

public CompositeElement()
Empty default constructor.


CompositeElement

public CompositeElement(List<? extends Element> components)
Empty default constructor.

Method Detail

setBeanFactory

public void setBeanFactory(BeanFactory beanFactory)
Specified by:
setBeanFactory in interface BeanFactoryAware

getComponents

protected List<Element> getComponents()

addComponent

protected void addComponent(Element element)
Adds the given element to the list of components. If a form as already been set initComponent(Element) is invoked, otherwise initialization is deferred until AbstractElement.setForm(Form) is called.

Parameters:
element - the element to add

removeComponent

protected void removeComponent(Element element)
Removes the given component. Note that the element is not unregistered from the form.


isEmpty

public boolean isEmpty()

afterFormSet

protected final void afterFormSet()
Invokes initComponent(Element) on all components and finally calls initCompositeElement().

Overrides:
afterFormSet in class AbstractElement

initCompositeElement

protected void initCompositeElement()
Subclasses may override this method to perform initialization tasks. A reference to the form will be set at this point and all components will be initialized. The default implementation does nothing.


processRequest

public void processRequest(FormRequest request)
Calls processRequestInternal() and afterwards processRequestComponents() to process the components.

Specified by:
processRequest in interface Element
Overrides:
processRequest in class AbstractElement

processRequestCompontents

protected void processRequestCompontents(FormRequest request)
Processes the request for all the components


initComponent

protected void initComponent(Element element)
Sets a reference to the form and registers the element by calling Form.registerElement(Element).

Throws:
IllegalStateException - if form is null

processRequestInternal

protected void processRequestInternal(FormRequest request)
Called before processRequest() is invoked on the contained elements. Subclasses can override this method to perform custom processing. The default implementation does nothing.


renderInternal

protected void renderInternal(PrintWriter writer)
Specified by:
renderInternal in class AbstractElement

focus

public void focus()
Delegates the call to the first component.

Specified by:
focus in interface Element
Overrides:
focus in class AbstractElement

isCompositeElement

public boolean isCompositeElement()
Helper method to check for composite elements in templates. Always returns true

Specified by:
isCompositeElement in interface Element
Overrides:
isCompositeElement in class AbstractElement