org.apache.myfaces.orchestra.dynaForm.jsf.component
Class DynaConfig

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by org.apache.myfaces.orchestra.dynaForm.jsf.component.DynaConfig
All Implemented Interfaces:
javax.faces.component.StateHolder

public class DynaConfig
extends javax.faces.component.UIComponentBase

Overrule the way DynaForm presents a specific persistent attribute.

The DynaForm uses a pluggable Extractor to analyse a particular class and determine what persistent properties it has, and how to render them. By default the dynaform will create a JSF component for each one of the detected persistent properties, using the detected metadata.

Any number of instances of this component can be added as children to a DynaForm component to override the settings auto-detected by the Extractor. Each instance overrides the properties of a single persistent field. The attribute "for" on this component should specify the name of the property to be overridden on the persistent object associated with the DynaForm.

This component can also have a single child component, in which case that is used as the component for rendering this dynamic field.


Field Summary
static String COMPONENT_FAMILY
           
static String COMPONENT_TYPE
           
 
Constructor Summary
DynaConfig()
           
 
Method Summary
 void configureMetaData(MetaFieldWritable field)
          Update the specified field with the settings the user has configured from this JSF component.
 Object getComponentHandler()
          Specifies the "controller bean" used to render this specific field.
 Boolean getDisabled()
           
 Boolean getDisplayOnly()
           
 Integer getDisplaySize()
           
 String getFamily()
           
 String getFor()
           
 Boolean getReadOnly()
           
 void restoreState(javax.faces.context.FacesContext context, Object stateArray)
           
 Object saveState(javax.faces.context.FacesContext context)
           
 void setComponentHandler(Object value)
          Specifies the "controller bean" used to render this specific field.
 void setDisabled(Boolean disabled)
          configure this field as disabled - like readOnly but grayed too
 void setDisplayOnly(Boolean displayOnly)
          set the field to display only
 void setDisplaySize(Integer displaySize)
          a hint for the size the ui should use when rendering the field
 void setFor(String forProperty)
          the name of the property this configuration is for
 void setReadOnly(Boolean readOnly)
          configure this field as readOnly - noneditable input field
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, broadcast, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesContext, getFacesListeners, getFacet, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_TYPE

public static final String COMPONENT_TYPE
See Also:
Constant Field Values

COMPONENT_FAMILY

public static final String COMPONENT_FAMILY
See Also:
Constant Field Values
Constructor Detail

DynaConfig

public DynaConfig()
Method Detail

getFamily

public String getFamily()
Specified by:
getFamily in class javax.faces.component.UIComponent

getDisplaySize

public Integer getDisplaySize()
See Also:
setDisplaySize(Integer)

setDisplaySize

public void setDisplaySize(Integer displaySize)
a hint for the size the ui should use when rendering the field


getDisplayOnly

public Boolean getDisplayOnly()
See Also:
setDisplayOnly(Boolean)

setDisplayOnly

public void setDisplayOnly(Boolean displayOnly)
set the field to display only


getReadOnly

public Boolean getReadOnly()
See Also:
setReadOnly(Boolean)

setReadOnly

public void setReadOnly(Boolean readOnly)
configure this field as readOnly - noneditable input field


getDisabled

public Boolean getDisabled()
See Also:
setDisabled(Boolean)

setDisabled

public void setDisabled(Boolean disabled)
configure this field as disabled - like readOnly but grayed too


getComponentHandler

public Object getComponentHandler()
Specifies the "controller bean" used to render this specific field.

This may return:

The configureMetaData method of this class just copies this setting into a MetaField object which is later used when building the components necessary to manage this field.

When the value is null, dynaform will create a default component to manage this field, depending on its type.

In the other cases, the DynaFormComponentHandler object is responsible for creating the necessary UI components to manage this field.

Normally, the JSP/Facelets framework will set this property to a String when the user provides a non-EL-expression, and will put a ValueBinding object into this component's value-binding map when the user provides an EL expression. As the value-binding could return a DynaFormComponentHandler or a String, this property type must be Object.


setComponentHandler

public void setComponentHandler(Object value)
Specifies the "controller bean" used to render this specific field.

This should be the name of a managed bean which implements DynaFormComponentHandler, or an actual DynaFormComponentHandler instance.


getFor

public String getFor()
See Also:
setFor(String)

setFor

public void setFor(String forProperty)
the name of the property this configuration is for


restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         Object stateArray)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.component.UIComponentBase

saveState

public Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class javax.faces.component.UIComponentBase

configureMetaData

public void configureMetaData(MetaFieldWritable field)
Update the specified field with the settings the user has configured from this JSF component.

This method is called after the user-specified extractor implementation is called. This means that any settings the user has defined in the JSF can override those auto-detected via the earlier extractor. However here we must only override earlier settings if they really have been set in the JSF config.



Copyright © 2012 The Apache Software Foundation. All Rights Reserved.