You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/02/25 16:08:07 UTC
svn commit: r630869 -
/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java
Author: skitching
Date: Mon Feb 25 07:08:03 2008
New Revision: 630869
URL: http://svn.apache.org/viewvc?rev=630869&view=rev
Log:
Add documentation only
Modified:
myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java
Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java?rev=630869&r1=630868&r2=630869&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java Mon Feb 25 07:08:03 2008
@@ -48,8 +48,19 @@
* A DynaForm component dynamically creates child jsf component objects to render
* all the persistent fields of an arbitrary java object.
* <p>
+ * 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".
+ * <p>
+ * 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.
+ * <p>
* The standard "value" property must be an EL expression that returns the object
- * whose properties are to be displayed or edited.
+ * whose properties are to be displayed or edited. When used within a UIData,
+ * this will normally return the "var" property of the datatable.
* <p>
* For documentation on the configurable properties of this component, see:
* <ul>
@@ -76,12 +87,12 @@
private String uri;
private String bundle;
- // private String var;
private String valueBindingPrefix;
private Boolean displayOnly;
private Boolean exclusiveFields;
private Boolean idAsDisplayOnly;
+ // TODO: why is this property marked with a JPA Transient annotation?
@Transient
private transient UriResolver.Configuration configuration = null;
@Transient
@@ -89,7 +100,17 @@
@Transient
private transient ELContext elcontext;
-
+ /**
+ * Create a UIColumn component to wrap a (label, value) pair of JSF components
+ * that represent a single persistent property. This class is used when the
+ * DynaForm is generating a "row per object" layout for a list of persistent
+ * objects.
+ * <p>
+ * TODO: before writing out the component, look for an existing component with that
+ * fieldname inside the parent. If it exists, then just skip the component creation.
+ * This allows the user to do custom layout for some of the fields. This might also
+ * make the @UIComponent annotation obsolete.
+ */
private final class AddComponentToTable implements NewComponentListener
{
private final UIComponent destCmp;
@@ -100,7 +121,7 @@
this.destCmp = component;
}
- @SuppressWarnings("unchecked")
+ // TODO: fieldName is an unused parameter
public void newComponent(String fieldName, UIComponent label, UIComponent component)
{
UIColumn column = new UIColumn();
@@ -124,6 +145,13 @@
}
}
+ /**
+ * Simply attach a (label, value) pair of JSF components that represent a
+ * single persistent property.
+ * <p>
+ * This class is used when the DynaForm is generating a plain "form style"
+ * layout for a single persistent object.
+ */
protected static class AddComponentSimple implements NewComponentListener
{
private final UIComponent destCmp;
@@ -134,7 +162,6 @@
this.destCmp = component;
}
- @SuppressWarnings("unchecked")
public void newComponent(String fieldName, UIComponent label, UIComponent component)
{
_FacesUtils.copyRendered(component, label);
@@ -267,19 +294,6 @@
}
/**
- * @see #setVar
- public String getVar()
- {
- if (var != null)
- {
- return var;
- }
- ValueBinding vb = getValueBinding("var");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
- */
-
- /**
* Display the whole form in read only mode, ie all the JSF components
* generated to display persistent properties are "read only".
*/
@@ -380,14 +394,6 @@
return false;
}
- /**
- * the var name used to allow access to the form controller
- public void setVar(String var)
- {
- this.var = var;
- }
- */
-
@Override
public void restoreState(FacesContext context, Object stateArray)
{
@@ -504,6 +510,11 @@
return null;
}
+ // TODO: this is not compatible with JSF1.1
+ // Some JVMs delay loading of referenced classes as long as possible, but this is not part
+ // of the java spec; any class A that has a ref to class B is not theoretically valid if
+ // B is not in the classpath - even if some JVMs don't actually throw an exception unless
+ // that class is used.
public ELContext getELContext()
{
return elcontext;
@@ -530,6 +541,19 @@
* <p>
* This component itself never has any components, and never generates any output
* into the response stream.
+ * <p>
+ * 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.
+ * <p>
+ * 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 initView(FacesContext context)
{