org.riotfamily.forms.factory
Class ConfigurableElementFactory

java.lang.Object
  extended by org.riotfamily.forms.factory.ConfigurableElementFactory
All Implemented Interfaces:
ElementFactory, ContainerElementFactory, EditorElementFactory

public class ConfigurableElementFactory
extends Object
implements ContainerElementFactory, EditorElementFactory

Configurable element factory that can be used to create arbitary form elements. This class is used by XmlFormRepositoryDigester but could also be useful for custom implementations.


Constructor Summary
ConfigurableElementFactory(Class<? extends Element> elementClass)
          Creates a new factory for the given element class.
 
Method Summary
 void addChildFactory(ElementFactory factory)
          Adds an ElementFactory to the list of child factories.
protected  void createChildElements(ContainerElement parent, Form form)
           
 Element createElement(Element parent, Form form, boolean bind)
          Returns a new instance of the configured element class.
protected  BeanEditor findEditor(Element parent, Form form)
           
 Class<?> getBeanClass()
           
 String getBind()
          Returns the name of the property that elements created by this factory shall be bound to or null if no binding should be performed.
 List<ElementFactory> getChildFactories()
          Returns a list of element factories used to create nested elements.
 Class<? extends Element> getElementClass()
           
protected  void populateElement(Element element)
          Called by #createElement(Element, Form) to populate the given element with the property values set via setPropertyValues(PropertyValues).
protected  Object resolveValueIfNecessary(Object value)
          Called by populateElement(Element) to support runtime references to prototype beans.
 void setBeanClass(Class<?> beanClass)
          If the factory is set up to create a BeanEditor, the type of the bean that is to be edited can be set.
 void setBeanFactory(ConfigurableListableBeanFactory beanFactory)
          Sets the BeanFactory that is used to lookup bean references.
 void setBind(String bind)
          Sets the name of the property that elements created by this factory shall be bound to.
 void setChildFactories(List<ElementFactory> childFactories)
          Sets a list of element factories that will be used to create child elements which will be added to the elements beeing created by this factory.
 void setPropertyValues(PropertyValues propertyValues)
          Sets the PropertyValues that will be set on the element after creation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurableElementFactory

public ConfigurableElementFactory(Class<? extends Element> elementClass)
Creates a new factory for the given element class.

Method Detail

getElementClass

public Class<? extends Element> getElementClass()

setBeanFactory

public void setBeanFactory(ConfigurableListableBeanFactory beanFactory)
Sets the BeanFactory that is used to lookup bean references.


setPropertyValues

public void setPropertyValues(PropertyValues propertyValues)
Sets the PropertyValues that will be set on the element after creation.


setBeanClass

public void setBeanClass(Class<?> beanClass)
If the factory is set up to create a BeanEditor, the type of the bean that is to be edited can be set.

Throws:
FormDefinitionException - if the element does not implement BeanEditor

getBeanClass

public Class<?> getBeanClass()
Returns:
Returns the beanClass.

setBind

public void setBind(String bind)
Sets the name of the property that elements created by this factory shall be bound to.

Throws:
FormDefinitionException - if the element does not implement Editor

getBind

public String getBind()
Returns the name of the property that elements created by this factory shall be bound to or null if no binding should be performed.

Specified by:
getBind in interface EditorElementFactory
See Also:
EditorElementFactory.getBind()

setChildFactories

public void setChildFactories(List<ElementFactory> childFactories)
Sets a list of element factories that will be used to create child elements which will be added to the elements beeing created by this factory.

Throws:
FormDefinitionException - if the element does not implement ContainerElement

addChildFactory

public void addChildFactory(ElementFactory factory)
Adds an ElementFactory to the list of child factories.

Specified by:
addChildFactory in interface ContainerElementFactory
See Also:
setChildFactories(List)

getChildFactories

public List<ElementFactory> getChildFactories()
Returns a list of element factories used to create nested elements.

Specified by:
getChildFactories in interface ContainerElementFactory
See Also:
setChildFactories(List)

createElement

public Element createElement(Element parent,
                             Form form,
                             boolean bind)
Returns a new instance of the configured element class.

Specified by:
createElement in interface ElementFactory
See Also:
ElementFactory.createElement(Element, Form, boolean)

populateElement

protected void populateElement(Element element)
Called by #createElement(Element, Form) to populate the given element with the property values set via setPropertyValues(PropertyValues). Values will be resolved if necessary by calling resolveValueIfNecessary(Object).


resolveValueIfNecessary

protected Object resolveValueIfNecessary(Object value)
Called by populateElement(Element) to support runtime references to prototype beans.

See Also:
RuntimeBeanReference

createChildElements

protected void createChildElements(ContainerElement parent,
                                   Form form)

findEditor

protected BeanEditor findEditor(Element parent,
                                Form form)