You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2007/11/08 16:12:35 UTC
svn commit: r593187 - in
/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm:
component/dynaForm/DynaForm.java guiBuilder/impl/jsf/JsfGuiBuilder.java
guiBuilder/impl/jsf/NewComponentListener.java
Author: imario
Date: Thu Nov 8 07:12:35 2007
New Revision: 593187
URL: http://svn.apache.org/viewvc?rev=593187&view=rev
Log:
set id on generated components, additional API (to make my Facelets components work)
Modified:
myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java
myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java
myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/NewComponentListener.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=593187&r1=593186&r2=593187&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 Thu Nov 8 07:12:35 2007
@@ -110,6 +110,16 @@
this.destCmp.getChildren().add(column);
}
+
+ public boolean containsComponent(String id)
+ {
+ return this.destCmp.findComponent(id) != null;
+ }
+
+ public UIComponent findComponent(String id)
+ {
+ return this.destCmp.findComponent(id);
+ }
}
protected static class AddComponentSimple implements NewComponentListener
@@ -126,10 +136,20 @@
public void newComponent(String fieldName, UIComponent label, UIComponent component)
{
_FacesUtils.copyRendered(component, label);
-
+
this.destCmp.getChildren().add(label);
this.destCmp.getChildren().add(component);
}
+
+ public boolean containsComponent(String id)
+ {
+ return this.destCmp.findComponent(id) != null;
+ }
+
+ public UIComponent findComponent(String id)
+ {
+ return this.destCmp.findComponent(id);
+ }
}
public DynaForm()
@@ -521,8 +541,8 @@
}
// create & add components
- boolean needAdd = processPreviouslyAdded(context, layoutComponent);
- if (needAdd)
+ // boolean needAdd = processPreviouslyAdded(context, layoutComponent);
+ // if (needAdd)
{
getAttributes().put(DynaForm.DYNA_FORM_URI, getUri());
addComponents(context, this, layoutComponent, viewType);
Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java?rev=593187&r1=593186&r2=593187&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java Thu Nov 8 07:12:35 2007
@@ -295,7 +295,7 @@
}
/**
- * Create an HtmlOutputLabel component, ie some text that
+ * Create an HtmlOutputLabel component, ie some text that
* specifically describes another input component.
* <p>
* The labelKey parameter is translated using a resource-bundle
@@ -740,6 +740,7 @@
UIOutput labelCmp = createLabelFor(field.getBaseName(), cmp);
cmp.getAttributes().put(DynaForm.DYNA_FORM_CREATED, Boolean.TRUE);
+
labelCmp.getAttributes().put(DynaForm.DYNA_FORM_CREATED, Boolean.TRUE);
newComponentListener.newComponent(field.getName(), labelCmp, cmp);
@@ -775,7 +776,7 @@
/**
* Return the first UIInput component in the tree of components starting at
- * the specified node (including the node itself).
+ * the specified node (including the node itself).
*/
public UIInput findInputComponent(UIComponent cmp)
{
@@ -812,8 +813,18 @@
{
if (field != null)
{
- cmp.setId(getCleanedNameForId(field.getExternalName()));
+ cmp.setId(getFieldId(field));
+ }
+ }
+
+ protected String getFieldId(FieldInterface field)
+ {
+ String idCandidate = field.getExternalName();
+ if (idCandidate == null)
+ {
+ idCandidate = field.getName();
}
+ return getCleanedNameForId(idCandidate);
}
/**
@@ -842,6 +853,7 @@
*/
public void initOutputDefaults(UIOutput cmp, FieldInterface field)
{
+ initDefaults(cmp, field);
initValueBinding(cmp, field);
initConverter(cmp, field);
}
@@ -1086,6 +1098,12 @@
@Override
protected boolean buildField(FieldInterface field)
{
+ String id = getFieldId(field);
+ if (newComponentListener.containsComponent(id))
+ {
+ return true;
+ }
+
if (field.getType() != null)
{
JsfGuiElementBuilder builder = builderMap.get(field.getType().getName());
Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/NewComponentListener.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/NewComponentListener.java?rev=593187&r1=593186&r2=593187&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/NewComponentListener.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/NewComponentListener.java Thu Nov 8 07:12:35 2007
@@ -32,4 +32,14 @@
* the new component and its label
*/
public void newComponent(String fieldName, UIComponent label, UIComponent component);
+
+ /**
+ * check if the component has been added already
+ */
+ public boolean containsComponent(String id);
+
+ /**
+ * find a component by id
+ */
+ public UIComponent findComponent(String id);
}