org.riotfamily.forms.element.collection
Class MapEditor

java.lang.Object
  extended by org.riotfamily.forms.AbstractElement
      extended by org.riotfamily.forms.AbstractEditorBase
          extended by org.riotfamily.forms.CompositeElement
              extended by org.riotfamily.forms.element.TemplateElement
                  extended by org.riotfamily.forms.element.collection.MapEditor
All Implemented Interfaces:
BackingObjectAware, Editor, Element, NestedEditor, BeanFactoryAware

public class MapEditor
extends TemplateElement
implements Editor, NestedEditor

A list widget to edit maps.


Nested Class Summary
 class MapEditor.MapItem
           
 
Field Summary
 
Fields inherited from class org.riotfamily.forms.AbstractElement
log
 
Constructor Summary
MapEditor()
           
 
Method Summary
protected  void addItem(Object key, Object value, boolean newItem)
           
 Editor getEditor(String property)
           
 Object getValue()
          Returns the value.
protected  void initCompositeElement()
          Subclasses may override this method to perform initialization tasks.
protected  void removeItem(MapEditor.MapItem item)
           
 void setBackingObject(Object obj)
           
 void setItemElementFactory(ElementFactory itemElementFactory)
          Sets the factory that is used to create an element for each map value.
 void setKeepNullValues(boolean keepNullValues)
           
 void setKeyElementFactory(ElementFactory keyElementFactory)
          Sets the factory that is used to create an element for each map key.
 void setKeyOptionsModel(Object keyOptionsModel)
           
 void setLabelProperty(String labelProperty)
           
 void setLabelRenderer(ObjectRenderer labelRenderer)
           
 void setMapClass(Class<?> mapClass)
          Sets the class to use if a new map instance needs to be created.
 void setRemoveUnknownKeys(boolean removeUnknownKeys)
           
 void setValue(Object value)
          Sets the (initial) value, typically retrieved from a backing object.
 
Methods inherited from class org.riotfamily.forms.element.TemplateElement
addComponent, afterFormContextSet, getAttribute, getRenderModel, getTemplate, renderInternal, renderTemplate, setAttribute, setTemplate
 
Methods inherited from class org.riotfamily.forms.CompositeElement
addComponent, afterFormSet, focus, getComponents, initComponent, isCompositeElement, isEmpty, processRequest, processRequestCompontents, processRequestInternal, removeComponent, setBeanFactory
 
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
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
 
Methods inherited from interface org.riotfamily.forms.Editor
addChangeListener, getEditorBinding, getFieldName, getLabel, setEditorBinding, setFieldName
 
Methods inherited from interface org.riotfamily.forms.Element
focus, getEventTriggerId, getForm, getFormContext, getId, getParent, getStyleClass, isCompositeElement, isEnabled, isRequired, isVisible, processRequest, render, setEnabled, setForm, setFormContext, setId, setParent, setRequired
 

Constructor Detail

MapEditor

public MapEditor()
Method Detail

setKeyOptionsModel

public void setKeyOptionsModel(Object keyOptionsModel)

setLabelProperty

public void setLabelProperty(String labelProperty)

setLabelRenderer

public void setLabelRenderer(ObjectRenderer labelRenderer)

setKeepNullValues

public void setKeepNullValues(boolean keepNullValues)

setRemoveUnknownKeys

public void setRemoveUnknownKeys(boolean removeUnknownKeys)

setKeyElementFactory

public void setKeyElementFactory(ElementFactory keyElementFactory)
Sets the factory that is used to create an element for each map key.


initCompositeElement

protected void initCompositeElement()
Description copied from class: CompositeElement
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.

Overrides:
initCompositeElement in class CompositeElement

setMapClass

public void setMapClass(Class<?> mapClass)
Sets the class to use if a new map instance needs to be created. Default is java.util.HashMap.

Parameters:
mapClass - the class to use for new collections

setItemElementFactory

public void setItemElementFactory(ElementFactory itemElementFactory)
Sets the factory that is used to create an element for each map value.


setValue

public void setValue(Object value)
Description copied from interface: Editor
Sets the (initial) value, typically retrieved from a backing object.

Specified by:
setValue in interface Editor

getValue

public Object getValue()
Description copied from interface: Editor
Returns the value.

Specified by:
getValue in interface Editor

setBackingObject

public void setBackingObject(Object obj)
Specified by:
setBackingObject in interface BackingObjectAware

getEditor

public Editor getEditor(String property)
Specified by:
getEditor in interface NestedEditor

addItem

protected void addItem(Object key,
                       Object value,
                       boolean newItem)

removeItem

protected void removeItem(MapEditor.MapItem item)