|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.faces.component.UIComponent
javax.faces.component.UIComponentBase
org.apache.myfaces.orchestra.dynaForm.jsf.component.DynaForm
public class DynaForm
A DynaForm component dynamically creates child jsf component objects to render all the persistent fields of an arbitrary java object.
This component can be nested within a UIData. In this case the data model of the UIData is assumed to be a list of persistent objects, each of which is of the type specified by the "uri" attribute of this component. A UIColumn component is generated for each persistent property of the class specified by "uri".
This component can also be used as a child of something other than a UIData, in which case it simply outputs a (label, field) pair of components for each persistent property of the class specified by the "uri" parameter. It is up to the parent component to lay out these component pairs appropriately.
The standard "value" property must be an EL expression that returns the object whose properties are to be displayed or edited. When used within a UIData, this will normally return the "var" property of the datatable.
For documentation on the configurable properties of this component, see:
setUri(String)
setValueBindingPrefix(String)
setDisplayOnly(boolean)
setBundle(String)
setUri(String)
setIdAsDisplayOnly(boolean)
Note that this class has no Renderer; this class dynamically modifies the component tree to add components, but has no actual representation itself and therefore needs no renderer. See method initView.
| Nested Class Summary | |
|---|---|
protected static class |
DynaForm.AddComponentSimple
Simply attach a (label, value) pair of JSF components that represent a single persistent property. |
protected static class |
DynaForm.AddComponentToTable
Create a UIColumn component to wrap a (label, value) pair of JSF components that represent a single persistent property. |
| Field Summary | |
|---|---|
static String |
COMPONENT_FAMILY
|
static String |
COMPONENT_TYPE
|
static String |
DEFAULT_RENDERER_TYPE
|
static String |
DYNA_FORM_CREATED
|
static String |
DYNA_FORM_URI
|
| Constructor Summary | |
|---|---|
DynaForm()
|
|
| Method Summary | |
|---|---|
protected void |
addComponents(javax.faces.context.FacesContext context,
DynaForm dynaForm,
javax.faces.component.UIComponent layoutComponent,
ViewType viewType)
create and add the components to the layout component. |
protected JsfGuiBuilder |
createGuiBuilder(javax.faces.context.FacesContext facesContext)
|
protected DynaForm |
findParentDynaForm(DynaForm start)
try to find a parent dyna form+ |
String |
getBundle()
|
protected UriResolver.Configuration |
getConfiguration()
Get the overall configuration based on the current value of the uri property. |
static DynaForm |
getDynaForm(javax.faces.component.UIComponent component)
Find the dynaForm component |
javax.el.ELContext |
getELContext()
Note that this method should only be called when _FacesUtils.useValueExpression is true. |
Extractor |
getExtractor()
|
String |
getFamily()
|
DynaConfigs |
getFormConfigs()
get access to the special form configurations |
NewComponentListener |
getNewComponentListener()
|
String |
getUri()
|
String |
getValueBindingPrefix()
|
protected String |
getValueBindingPrefix(DynaForm dynaForm,
javax.faces.component.UIComponent layoutComponent)
|
protected ViewType |
getViewType(javax.faces.component.UIComponent startComponent)
determine the current view type "list" means: the layout component "is a" or "is embedded in an" list component (UIData) "form" means: anything else |
void |
initView(javax.faces.context.FacesContext context)
Dynamically compute and add child components to the current tree. |
boolean |
isDisplayOnly()
|
boolean |
isExclusiveFields()
|
boolean |
isIdAsDisplayOnly()
|
boolean |
isRendered()
|
protected boolean |
processPreviouslyAdded(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent root)
check if we already added components to the layout component. if this is the case then: keep them cached and avoid readd |
void |
removeDynaFormCreatedComponents(javax.faces.component.UIComponent base)
|
void |
restoreState(javax.faces.context.FacesContext context,
Object stateArray)
|
Object |
saveState(javax.faces.context.FacesContext context)
|
void |
setBundle(String bundle)
The bundle to use to convert property names to localised label strings. |
void |
setDisplayOnly(boolean displayOnly)
Display the whole form in read only mode, ie all the JSF components generated to display persistent properties are "read only". |
void |
setELContext(javax.el.ELContext elcontext)
|
void |
setExclusiveFields(boolean exclusiveFields)
Process only fields listed by their facets |
void |
setIdAsDisplayOnly(boolean idAsDisplayOnly)
Display id fields (ie the key fields of the persistent object) in the form in read only mode. |
void |
setNewComponentListener(NewComponentListener newComponentListener)
Normally DynaForm will try to figure out how to add components to the JSF tree. |
void |
setUri(String uri)
Specifies how to obtain the metadata for the value object. |
void |
setValueBindingPrefix(String valueBindingPrefix)
Specify how to get and set the model value for each persistent property of the value object. |
| 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, 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 |
|---|
public static final String COMPONENT_TYPE
public static final String DEFAULT_RENDERER_TYPE
public static final String COMPONENT_FAMILY
public static final String DYNA_FORM_CREATED
public static final String DYNA_FORM_URI
| Constructor Detail |
|---|
public DynaForm()
| Method Detail |
|---|
public String getFamily()
getFamily in class javax.faces.component.UIComponentpublic NewComponentListener getNewComponentListener()
setNewComponentListener(org.apache.myfaces.orchestra.dynaForm.jsf.guiBuilder.impl.jsf.NewComponentListener)public void setNewComponentListener(NewComponentListener newComponentListener)
NewComponentListener.
public String getUri()
setUri(java.lang.String)public void setUri(String uri)
This is a string of form "inspector:classname". The inspector part ndicates which of the configured Extractor implementations should be used to obtain the metadata for this class. The classname is of course the concrete class of the specified object.
For example, "ejb:fqn.to.model.Entity" means use the EJB3-based extractor implementation to obtain metadata about the given entity
TODO: why can't value.getClass() be used for the classname part of the uri? Maybe because the value EL expression can map to a null property when creating a new instance?
UriResolverpublic String getValueBindingPrefix()
setValueBindingPrefix(java.lang.String)public void setValueBindingPrefix(String valueBindingPrefix)
When the JSF components that correspond to the individual persistent properties of the value object are created, they need EL expressions to tell them how to access the corresponding model value.
The EL expression used for each created component is of form
#{valueBindingPrefix.propname}.
Of course valueBindingPrefix will normally refer to the same object that the "value" property refers to. In fact, there probably isn't any other sane value for this property.
TODO: Can we get rid of this attribute? Either call
getValueBinding().getExpressionString() or create a special
ValueBinding subclass that takes a "base object" parameter which we can
point at the result of evaluating the main value expression.
public String getBundle()
setBundle(java.lang.String)public void setBundle(String bundle)
For each persistent property on the value object, a pair of components (label and value) are created. The label text is computed by using the persistent property name as a key into the specified bundle.
This must be the name of a managed bean that implements Map.
public void setDisplayOnly(boolean displayOnly)
public boolean isDisplayOnly()
setDisplayOnly(boolean)public void setIdAsDisplayOnly(boolean idAsDisplayOnly)
Defaults to false.
When editing existing objects this should be set to true, as it is not possible to modify the key of an existing entity. When creating a new instance this should be set to true if the key is an auto-generated surrogate key, but false if the key to this entity is a "business key".
public boolean isIdAsDisplayOnly()
setIdAsDisplayOnly(boolean)public void setExclusiveFields(boolean exclusiveFields)
TODO: document this properly. What does this do exactly??
public boolean isExclusiveFields()
setExclusiveFields(boolean)
public void restoreState(javax.faces.context.FacesContext context,
Object stateArray)
restoreState in interface javax.faces.component.StateHolderrestoreState in class javax.faces.component.UIComponentBasepublic Object saveState(javax.faces.context.FacesContext context)
saveState in interface javax.faces.component.StateHoldersaveState in class javax.faces.component.UIComponentBaseprotected UriResolver.Configuration getConfiguration()
This returns an object that simply pairs an Extractor object with the remaining part of the URI. The Extractor instance selected is specified by the "protocol" part of the URI.
UriResolverpublic Extractor getExtractor()
protected DynaForm findParentDynaForm(DynaForm start)
public static DynaForm getDynaForm(javax.faces.component.UIComponent component)
public DynaConfigs getFormConfigs()
public javax.el.ELContext getELContext()
This is needed when using either JSF1.2 or (JSF1.1 + facelets).
It is still not clear why we need this anyway; instead of storing a context for later use, why not just use the context available at the time an expression must be evaluated?
public void setELContext(javax.el.ELContext elcontext)
public boolean isRendered()
isRendered in class javax.faces.component.UIComponentBasepublic void initView(javax.faces.context.FacesContext context)
This method is required to be invoked from the TagHandler when an instance of this component is created. Components are created based upon the class specified by the "uri" property, and added as children of the parent component of this component.
This component itself never has any components, and never generates any output into the response stream.
It would be much nicer if this component could be the parent of the components it dynamically creates, but that doesn't work well with an h:panelGrid or h:dataTable component as the parent; a panelGrid counts its children while a dataTable counts its UIColumn children. To make things work, the created components must therefore be direct children of the parent. Note that this component is also a child of the parent, but because it marks itself as rendered=false it does not affect the behaviour of parent components that count their (rendered) children.
Note also that although this method is capable of deleting previously-created components and creating a new set, at the moment this method is only invoked by the taghandler when this component is created. That means that the "uri" parameter is only used on first access to the view, and is ignored thereafter.
public void removeDynaFormCreatedComponents(javax.faces.component.UIComponent base)
protected ViewType getViewType(javax.faces.component.UIComponent startComponent)
protected void addComponents(javax.faces.context.FacesContext context,
DynaForm dynaForm,
javax.faces.component.UIComponent layoutComponent,
ViewType viewType)
protected String getValueBindingPrefix(DynaForm dynaForm,
javax.faces.component.UIComponent layoutComponent)
protected JsfGuiBuilder createGuiBuilder(javax.faces.context.FacesContext facesContext)
protected boolean processPreviouslyAdded(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent root)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||