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/07/03 23:58:25 UTC
svn commit: r673833 [15/18] - in /myfaces/tomahawk/trunk:
core/src/main/java/org/apache/myfaces/component/
core/src/main/java/org/apache/myfaces/component/html/ext/
core/src/main/java/org/apache/myfaces/component/html/util/
core/src/main/java/org/apach...
Modified: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfig.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfig.java (original)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfig.java Thu Jul 3 14:58:05 2008
@@ -31,164 +31,164 @@
*/
public class DynaConfig extends UIComponentBase
{
- public static final String COMPONENT_TYPE = "org.apache.myfaces.dynaForm.DynaConfig";
- public static final String COMPONENT_FAMILY = "org.apache.myfaces.dynaForm.DynaConfig";
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.dynaForm.DynaConfig";
+ public static final String COMPONENT_FAMILY = "org.apache.myfaces.dynaForm.DynaConfig";
- private String forProperty;
- private Integer displaySize;
- private Boolean displayOnly;
- private Boolean readOnly;
- private Boolean disabled;
-
- @Override
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
-
- /**
- * @see #setDisplaySize(Integer)
- */
- public Integer getDisplaySize()
- {
- if (displaySize != null)
- return displaySize;
- ValueBinding vb = getValueBinding("displaySize");
- return vb != null ? (Integer) vb.getValue(getFacesContext()) : null;
- }
-
- /**
- * a hint for the size the ui should use when rendering the field
- */
- public void setDisplaySize(Integer displaySize)
- {
- this.displaySize = displaySize;
- }
-
- /**
- * @see #setDisplayOnly(Boolean)
- */
- public Boolean getDisplayOnly()
- {
- if (displayOnly != null)
- return displayOnly;
- ValueBinding vb = getValueBinding("displayOnly");
- return vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
- }
-
- /**
- * set the field to display only
- */
- public void setDisplayOnly(Boolean displayOnly)
- {
- this.displayOnly = displayOnly;
- }
-
- /**
- * @see #setReadOnly(Boolean)
- */
- public Boolean getReadOnly()
- {
- if (readOnly != null)
- return readOnly;
- ValueBinding vb = getValueBinding("readOnly");
- return vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
- }
-
- /**
- * configure this field as readOnly - noneditable input field
- */
- public void setReadOnly(Boolean readOnly)
- {
- this.readOnly = readOnly;
- }
-
- /**
- * @see #setDisabled(Boolean)
- */
- public Boolean getDisabled()
- {
- if (disabled != null)
- return disabled;
- ValueBinding vb = getValueBinding("disabled");
- return vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
- }
-
- /**
- * configure this field as disabled - like readOnly but grayed too
- */
- public void setDisabled(Boolean disabled)
- {
- this.disabled = disabled;
- }
-
- /**
- * @see #setFor(String)
- */
- public String getFor()
- {
- if (forProperty != null)
- return forProperty;
- ValueBinding vb = getValueBinding("for");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- /**
- * the name of the property this configuration is for
- */
- public void setFor(String forProperty)
- {
- this.forProperty = forProperty;
- }
-
- @Override
- public void restoreState(FacesContext context, Object stateArray)
- {
- Object[] states = (Object[]) stateArray;
- super.restoreState(context, states[0]);
- displaySize = (Integer) states[1];
- forProperty = (String) states[2];
- displayOnly = (Boolean) states[3];
- readOnly = (Boolean) states[4];
- disabled = (Boolean) states[5];
- }
-
- @Override
- public Object saveState(FacesContext context)
- {
- return new Object[]
- {
- super.saveState(context),
- displaySize,
- forProperty,
- displayOnly,
- readOnly,
- disabled
- };
- }
-
- public void configureMetaData(FieldImpl field)
- {
- if (getDisplaySize() != null)
- {
- field.setDisplaySize(getDisplaySize().intValue());
- }
- if (getDisplayOnly() != null)
- {
- field.setDisplayOnly(getDisplayOnly());
- }
- if (getReadOnly() != null)
- {
- field.setCanWrite(getReadOnly().booleanValue());
- }
- if (getDisabled() != null)
- {
- field.setDisabled(getDisabled().booleanValue());
- }
-
- if (getChildCount() > 0)
- {
- field.setWantedComponent((UIComponent) getChildren().get(0));
- }
- }
+ private String forProperty;
+ private Integer displaySize;
+ private Boolean displayOnly;
+ private Boolean readOnly;
+ private Boolean disabled;
+
+ @Override
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ /**
+ * @see #setDisplaySize(Integer)
+ */
+ public Integer getDisplaySize()
+ {
+ if (displaySize != null)
+ return displaySize;
+ ValueBinding vb = getValueBinding("displaySize");
+ return vb != null ? (Integer) vb.getValue(getFacesContext()) : null;
+ }
+
+ /**
+ * a hint for the size the ui should use when rendering the field
+ */
+ public void setDisplaySize(Integer displaySize)
+ {
+ this.displaySize = displaySize;
+ }
+
+ /**
+ * @see #setDisplayOnly(Boolean)
+ */
+ public Boolean getDisplayOnly()
+ {
+ if (displayOnly != null)
+ return displayOnly;
+ ValueBinding vb = getValueBinding("displayOnly");
+ return vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
+ }
+
+ /**
+ * set the field to display only
+ */
+ public void setDisplayOnly(Boolean displayOnly)
+ {
+ this.displayOnly = displayOnly;
+ }
+
+ /**
+ * @see #setReadOnly(Boolean)
+ */
+ public Boolean getReadOnly()
+ {
+ if (readOnly != null)
+ return readOnly;
+ ValueBinding vb = getValueBinding("readOnly");
+ return vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
+ }
+
+ /**
+ * configure this field as readOnly - noneditable input field
+ */
+ public void setReadOnly(Boolean readOnly)
+ {
+ this.readOnly = readOnly;
+ }
+
+ /**
+ * @see #setDisabled(Boolean)
+ */
+ public Boolean getDisabled()
+ {
+ if (disabled != null)
+ return disabled;
+ ValueBinding vb = getValueBinding("disabled");
+ return vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
+ }
+
+ /**
+ * configure this field as disabled - like readOnly but grayed too
+ */
+ public void setDisabled(Boolean disabled)
+ {
+ this.disabled = disabled;
+ }
+
+ /**
+ * @see #setFor(String)
+ */
+ public String getFor()
+ {
+ if (forProperty != null)
+ return forProperty;
+ ValueBinding vb = getValueBinding("for");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ /**
+ * the name of the property this configuration is for
+ */
+ public void setFor(String forProperty)
+ {
+ this.forProperty = forProperty;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object stateArray)
+ {
+ Object[] states = (Object[]) stateArray;
+ super.restoreState(context, states[0]);
+ displaySize = (Integer) states[1];
+ forProperty = (String) states[2];
+ displayOnly = (Boolean) states[3];
+ readOnly = (Boolean) states[4];
+ disabled = (Boolean) states[5];
+ }
+
+ @Override
+ public Object saveState(FacesContext context)
+ {
+ return new Object[]
+ {
+ super.saveState(context),
+ displaySize,
+ forProperty,
+ displayOnly,
+ readOnly,
+ disabled
+ };
+ }
+
+ public void configureMetaData(FieldImpl field)
+ {
+ if (getDisplaySize() != null)
+ {
+ field.setDisplaySize(getDisplaySize().intValue());
+ }
+ if (getDisplayOnly() != null)
+ {
+ field.setDisplayOnly(getDisplayOnly());
+ }
+ if (getReadOnly() != null)
+ {
+ field.setCanWrite(getReadOnly().booleanValue());
+ }
+ if (getDisabled() != null)
+ {
+ field.setDisabled(getDisabled().booleanValue());
+ }
+
+ if (getChildCount() > 0)
+ {
+ field.setWantedComponent((UIComponent) getChildren().get(0));
+ }
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigTag.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigTag.java Thu Jul 3 14:58:05 2008
@@ -24,117 +24,117 @@
public class DynaConfigTag extends UIComponentBodyTagBase
{
- private String displaySize;
- private String forProperty;
- private String displayOnly;
- private String readOnly;
- private String disabled;
-
- public void release()
- {
- super.release();
-
- displaySize = null;
- forProperty = null;
- }
-
- protected void setProperties(UIComponent component)
- {
- super.setProperties(component);
- setIntegerProperty(component, "displaySize", displaySize);
- setStringProperty(component, "for", forProperty);
- setBooleanProperty(component, "displayOnly", displayOnly);
- setBooleanProperty(component, "readOnly", readOnly);
- setBooleanProperty(component, "disabled", disabled);
- }
-
- /**
- * @see DynaConfig#setDisplaySize(Integer)
- */
- public String getDisplaySize()
- {
- return displaySize;
- }
-
- /**
- * @see DynaConfig#setDisplaySize(Integer)
- */
- public void setDisplaySize(String size)
- {
- this.displaySize = size;
- }
-
- /**
- * @see DynaConfig#setFor(String)
- */
- public String getFor()
- {
- return forProperty;
- }
-
- /**
- * @see DynaConfig#setFor(String)
- */
- public void setFor(String forProperty)
- {
- this.forProperty = forProperty;
- }
-
- /**
- * @see DynaConfig#setDisplayOnly(Boolean)
- */
- public String getDisplayOnly()
- {
- return displayOnly;
- }
-
- /**
- * @see DynaConfig#setDisplayOnly(Boolean)
- */
- public void setDisplayOnly(String displayOnly)
- {
- this.displayOnly = displayOnly;
- }
-
- /**
- * @see DynaConfig#setDisabled(Boolean)
- */
- public String getDisabled()
- {
- return disabled;
- }
-
- /**
- * @see DynaConfig#setDisabled(Boolean)
- */
- public void setDisabled(String disabled)
- {
- this.disabled = disabled;
- }
-
- /**
- * @see DynaConfig#setReadOnly(Boolean)
- */
- public String getReadOnly()
- {
- return readOnly;
- }
-
- /**
- * @see DynaConfig#setReadOnly(Boolean)
- */
- public void setReadOnly(String readOnly)
- {
- this.readOnly = readOnly;
- }
-
- public String getComponentType()
- {
- return DynaConfig.COMPONENT_TYPE;
- }
-
- public String getRendererType()
- {
- return null;
- }
+ private String displaySize;
+ private String forProperty;
+ private String displayOnly;
+ private String readOnly;
+ private String disabled;
+
+ public void release()
+ {
+ super.release();
+
+ displaySize = null;
+ forProperty = null;
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setIntegerProperty(component, "displaySize", displaySize);
+ setStringProperty(component, "for", forProperty);
+ setBooleanProperty(component, "displayOnly", displayOnly);
+ setBooleanProperty(component, "readOnly", readOnly);
+ setBooleanProperty(component, "disabled", disabled);
+ }
+
+ /**
+ * @see DynaConfig#setDisplaySize(Integer)
+ */
+ public String getDisplaySize()
+ {
+ return displaySize;
+ }
+
+ /**
+ * @see DynaConfig#setDisplaySize(Integer)
+ */
+ public void setDisplaySize(String size)
+ {
+ this.displaySize = size;
+ }
+
+ /**
+ * @see DynaConfig#setFor(String)
+ */
+ public String getFor()
+ {
+ return forProperty;
+ }
+
+ /**
+ * @see DynaConfig#setFor(String)
+ */
+ public void setFor(String forProperty)
+ {
+ this.forProperty = forProperty;
+ }
+
+ /**
+ * @see DynaConfig#setDisplayOnly(Boolean)
+ */
+ public String getDisplayOnly()
+ {
+ return displayOnly;
+ }
+
+ /**
+ * @see DynaConfig#setDisplayOnly(Boolean)
+ */
+ public void setDisplayOnly(String displayOnly)
+ {
+ this.displayOnly = displayOnly;
+ }
+
+ /**
+ * @see DynaConfig#setDisabled(Boolean)
+ */
+ public String getDisabled()
+ {
+ return disabled;
+ }
+
+ /**
+ * @see DynaConfig#setDisabled(Boolean)
+ */
+ public void setDisabled(String disabled)
+ {
+ this.disabled = disabled;
+ }
+
+ /**
+ * @see DynaConfig#setReadOnly(Boolean)
+ */
+ public String getReadOnly()
+ {
+ return readOnly;
+ }
+
+ /**
+ * @see DynaConfig#setReadOnly(Boolean)
+ */
+ public void setReadOnly(String readOnly)
+ {
+ this.readOnly = readOnly;
+ }
+
+ public String getComponentType()
+ {
+ return DynaConfig.COMPONENT_TYPE;
+ }
+
+ public String getRendererType()
+ {
+ return null;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigs.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigs.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigs.java (original)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigs.java Thu Jul 3 14:58:05 2008
@@ -29,49 +29,49 @@
*/
public class DynaConfigs extends UIComponentBase
{
- public static final String COMPONENT_TYPE = "org.apache.myfaces.dynaForm.DynaConfigs";
- public static final String COMPONENT_FAMILY = "org.apache.myfaces.dynaForm.DynaConfigs";
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.dynaForm.DynaConfigs";
+ public static final String COMPONENT_FAMILY = "org.apache.myfaces.dynaForm.DynaConfigs";
- private transient Map<String, DynaConfig> configMap = null;
+ private transient Map<String, DynaConfig> configMap = null;
- @Override
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
-
- public DynaConfig getConfig(String name)
- {
- Map<String, DynaConfig> configMap = getConfigMap();
- return configMap.get(name);
- }
-
- protected Map<String, DynaConfig> getConfigMap()
- {
- if (configMap != null)
- {
- return configMap;
- }
- configMap = new LinkedHashMap<String, DynaConfig>();
-
- for (Object child : getChildren())
- {
- if (child instanceof DynaConfig)
- {
- DynaConfig dynaConfig = (DynaConfig) child;
- if (configMap.containsKey(dynaConfig.getFor()))
- {
- throw new IllegalStateException("duplicate config for property '" + dynaConfig.getFor() + "'");
- }
- configMap.put(dynaConfig.getFor(), dynaConfig);
- }
- }
-
- return configMap;
- }
-
- public Iterator<DynaConfig> iterator()
- {
- return getConfigMap().values().iterator();
- }
+ @Override
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ public DynaConfig getConfig(String name)
+ {
+ Map<String, DynaConfig> configMap = getConfigMap();
+ return configMap.get(name);
+ }
+
+ protected Map<String, DynaConfig> getConfigMap()
+ {
+ if (configMap != null)
+ {
+ return configMap;
+ }
+ configMap = new LinkedHashMap<String, DynaConfig>();
+
+ for (Object child : getChildren())
+ {
+ if (child instanceof DynaConfig)
+ {
+ DynaConfig dynaConfig = (DynaConfig) child;
+ if (configMap.containsKey(dynaConfig.getFor()))
+ {
+ throw new IllegalStateException("duplicate config for property '" + dynaConfig.getFor() + "'");
+ }
+ configMap.put(dynaConfig.getFor(), dynaConfig);
+ }
+ }
+
+ return configMap;
+ }
+
+ public Iterator<DynaConfig> iterator()
+ {
+ return getConfigMap().values().iterator();
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigsTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigsTag.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigsTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaConfigsTag.java Thu Jul 3 14:58:05 2008
@@ -22,18 +22,18 @@
public class DynaConfigsTag extends UIComponentBodyTagBase
{
- public void release()
- {
- super.release();
- }
+ public void release()
+ {
+ super.release();
+ }
- public String getComponentType()
- {
- return DynaConfigs.COMPONENT_TYPE;
- }
+ public String getComponentType()
+ {
+ return DynaConfigs.COMPONENT_TYPE;
+ }
- public String getRendererType()
- {
- return null;
- }
+ public String getRendererType()
+ {
+ return null;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaForm.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaForm.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaForm.java (original)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaForm.java Thu Jul 3 14:58:05 2008
@@ -309,9 +309,9 @@
{
formConfigs = (DynaConfigs) obj;
return formConfigs;
- }
- }
+ }
+ }
- return null;
- }
+ return null;
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaFormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaFormRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaFormRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaFormRenderer.java Thu Jul 3 14:58:05 2008
@@ -46,104 +46,104 @@
*/
public class DynaFormRenderer extends Renderer
{
- public final static String CONTEXT_GUI_BUILDER = "org.apache.myfaces.custom.dynaForm.GUI_BUILDER";
+ public final static String CONTEXT_GUI_BUILDER = "org.apache.myfaces.custom.dynaForm.GUI_BUILDER";
- private final class AddComponentToTable implements NewComponentListener
- {
- private final UIComponent destCmp;
-
- private AddComponentToTable(UIComponent component)
- {
- super();
- this.destCmp = component;
- }
-
- @SuppressWarnings("unchecked")
- public void newComponent(String fieldName, UIComponent label, UIComponent component)
- {
- component.getAttributes().put(
- DynaForm.DYNA_FORM_CREATED, Boolean.TRUE);
-
- UIColumn column = new UIColumn();
- column.getChildren().add(component);
- column.setHeader(label);
-
- int addPos = -1;
- UIComponent dataIndicator = this.destCmp.findComponent("data");
- if (dataIndicator != null)
- {
- addPos = this.destCmp.getChildren().indexOf(dataIndicator);
- }
-
- if (addPos > -1)
- {
- this.destCmp.getChildren().add(addPos, column);
- }
- else
- {
- this.destCmp.getChildren().add(column);
- }
- }
- }
-
- protected static class AddComponentSimple implements NewComponentListener
- {
- private final UIComponent destCmp;
-
- protected AddComponentSimple(UIComponent component)
- {
- super();
- this.destCmp = component;
- }
-
- @SuppressWarnings("unchecked")
- public void newComponent(String fieldName, UIComponent label, UIComponent component)
- {
- component.getAttributes().put(
- DynaForm.DYNA_FORM_CREATED, Boolean.TRUE);
-
- this.destCmp.getChildren().add(label);
- this.destCmp.getChildren().add(component);
- }
- }
-
- @Override
- public boolean getRendersChildren()
- {
- return true;
- }
-
- /**
- * on create view or in development mode this will build the component tree
- */
- @Override
- public void encodeBegin(FacesContext context, UIComponent component)
- throws IOException
- {
- super.encodeBegin(context, component);
-
- DynaForm dynaForm = (DynaForm) component;
-
- UIComponent layoutComponent = findLayoutComponent(dynaForm);
- ViewType viewType = getViewType(layoutComponent);
-
- // create & add components
- boolean needAdd = processPreviouslyAdded(context, layoutComponent);
- if (needAdd)
- {
- addComponents(context, dynaForm, layoutComponent, viewType);
- }
- }
-
- /**
- * determine the current view type
- * <ul>
- * <li>"list" means: the layout component "is a" or "is embedded in an" list component (UIData)</li>
- * <li>"form" means: anything else</li>
- * </ul>
- */
- protected ViewType getViewType(UIComponent startComponent)
- {
+ private final class AddComponentToTable implements NewComponentListener
+ {
+ private final UIComponent destCmp;
+
+ private AddComponentToTable(UIComponent component)
+ {
+ super();
+ this.destCmp = component;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void newComponent(String fieldName, UIComponent label, UIComponent component)
+ {
+ component.getAttributes().put(
+ DynaForm.DYNA_FORM_CREATED, Boolean.TRUE);
+
+ UIColumn column = new UIColumn();
+ column.getChildren().add(component);
+ column.setHeader(label);
+
+ int addPos = -1;
+ UIComponent dataIndicator = this.destCmp.findComponent("data");
+ if (dataIndicator != null)
+ {
+ addPos = this.destCmp.getChildren().indexOf(dataIndicator);
+ }
+
+ if (addPos > -1)
+ {
+ this.destCmp.getChildren().add(addPos, column);
+ }
+ else
+ {
+ this.destCmp.getChildren().add(column);
+ }
+ }
+ }
+
+ protected static class AddComponentSimple implements NewComponentListener
+ {
+ private final UIComponent destCmp;
+
+ protected AddComponentSimple(UIComponent component)
+ {
+ super();
+ this.destCmp = component;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void newComponent(String fieldName, UIComponent label, UIComponent component)
+ {
+ component.getAttributes().put(
+ DynaForm.DYNA_FORM_CREATED, Boolean.TRUE);
+
+ this.destCmp.getChildren().add(label);
+ this.destCmp.getChildren().add(component);
+ }
+ }
+
+ @Override
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ /**
+ * on create view or in development mode this will build the component tree
+ */
+ @Override
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException
+ {
+ super.encodeBegin(context, component);
+
+ DynaForm dynaForm = (DynaForm) component;
+
+ UIComponent layoutComponent = findLayoutComponent(dynaForm);
+ ViewType viewType = getViewType(layoutComponent);
+
+ // create & add components
+ boolean needAdd = processPreviouslyAdded(context, layoutComponent);
+ if (needAdd)
+ {
+ addComponents(context, dynaForm, layoutComponent, viewType);
+ }
+ }
+
+ /**
+ * determine the current view type
+ * <ul>
+ * <li>"list" means: the layout component "is a" or "is embedded in an" list component (UIData)</li>
+ * <li>"form" means: anything else</li>
+ * </ul>
+ */
+ protected ViewType getViewType(UIComponent startComponent)
+ {
UIComponent component = startComponent;
while (component != null && !(component instanceof DynaForm))
{
@@ -156,98 +156,98 @@
}
return ViewType.FORM;
- }
+ }
- protected UIComponent findLayoutComponent(DynaForm dynaForm)
- {
- UIComponent layoutComponent = findComponentEx(dynaForm, dynaForm.getVar() + "-layout");
- if (layoutComponent == null)
- {
- throw new IllegalStateException("DynaForm '" + dynaForm.getId()
- + "' has no layout component (id=\"layout\")");
- }
- return layoutComponent;
- }
-
- /**
- * find a component "by id" by simply traversing the tree
- */
- protected UIComponent findComponentEx(UIComponent base, String id)
- {
- if (id.equals(base.getId()))
- {
- return base;
- }
-
- Iterator iterChildren = base.getFacetsAndChildren();
- while (iterChildren.hasNext())
- {
- UIComponent child = (UIComponent) iterChildren.next();
- UIComponent found = findComponentEx(child, id);
- if (found != null)
- {
- return found;
- }
- }
-
- return null;
- }
-
- /**
- * collect all input components recursiv starting with <code>component</code>
- */
- protected void collectInputComponents(List<UIInput> components, UIComponent baseComponent)
- {
- if (baseComponent instanceof UIInput)
- {
- components.add((UIInput) baseComponent);
- }
-
- if (baseComponent.getChildren() == null)
- {
- return;
- }
-
- for (Object component : baseComponent.getChildren())
- {
- UIComponent componentChild = (UIComponent) component;
- collectInputComponents(components, componentChild);
- }
- }
-
- /**
- * create and add the components to the layout component
- */
- protected void addComponents(final FacesContext context,
- final DynaForm dynaForm, final UIComponent layoutComponent,
- final ViewType viewType)
- {
- MetaData metaData = extractMetaData(dynaForm);
-
- Slipstream slipstream = new Slipstream();
- slipstream.setModelMetaData(metaData);
- slipstream.setDisplayOnly(dynaForm.isDisplayOnly());
-
- if (dynaForm.getBundle() != null)
- {
- // get the bundle and attach it
- Map bundleMap = (Map) context.getApplication().createValueBinding("#{" + dynaForm.getBundle() + "}").getValue(context);
- slipstream.setLabelBundle(bundleMap);
- }
-
- JsfGuiBuilder guiBuilder = createGuiBuilder(context);
-
- guiBuilder.setContext(context);
- guiBuilder.setBackingBeanPrefix(dynaForm.getVar());
-
- if (isTable(layoutComponent))
- {
- guiBuilder.setNewComponentListener(new AddComponentToTable(layoutComponent));
- }
- else
- {
- guiBuilder.setNewComponentListener(new AddComponentSimple(layoutComponent));
- }
+ protected UIComponent findLayoutComponent(DynaForm dynaForm)
+ {
+ UIComponent layoutComponent = findComponentEx(dynaForm, dynaForm.getVar() + "-layout");
+ if (layoutComponent == null)
+ {
+ throw new IllegalStateException("DynaForm '" + dynaForm.getId()
+ + "' has no layout component (id=\"layout\")");
+ }
+ return layoutComponent;
+ }
+
+ /**
+ * find a component "by id" by simply traversing the tree
+ */
+ protected UIComponent findComponentEx(UIComponent base, String id)
+ {
+ if (id.equals(base.getId()))
+ {
+ return base;
+ }
+
+ Iterator iterChildren = base.getFacetsAndChildren();
+ while (iterChildren.hasNext())
+ {
+ UIComponent child = (UIComponent) iterChildren.next();
+ UIComponent found = findComponentEx(child, id);
+ if (found != null)
+ {
+ return found;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * collect all input components recursiv starting with <code>component</code>
+ */
+ protected void collectInputComponents(List<UIInput> components, UIComponent baseComponent)
+ {
+ if (baseComponent instanceof UIInput)
+ {
+ components.add((UIInput) baseComponent);
+ }
+
+ if (baseComponent.getChildren() == null)
+ {
+ return;
+ }
+
+ for (Object component : baseComponent.getChildren())
+ {
+ UIComponent componentChild = (UIComponent) component;
+ collectInputComponents(components, componentChild);
+ }
+ }
+
+ /**
+ * create and add the components to the layout component
+ */
+ protected void addComponents(final FacesContext context,
+ final DynaForm dynaForm, final UIComponent layoutComponent,
+ final ViewType viewType)
+ {
+ MetaData metaData = extractMetaData(dynaForm);
+
+ Slipstream slipstream = new Slipstream();
+ slipstream.setModelMetaData(metaData);
+ slipstream.setDisplayOnly(dynaForm.isDisplayOnly());
+
+ if (dynaForm.getBundle() != null)
+ {
+ // get the bundle and attach it
+ Map bundleMap = (Map) context.getApplication().createValueBinding("#{" + dynaForm.getBundle() + "}").getValue(context);
+ slipstream.setLabelBundle(bundleMap);
+ }
+
+ JsfGuiBuilder guiBuilder = createGuiBuilder(context);
+
+ guiBuilder.setContext(context);
+ guiBuilder.setBackingBeanPrefix(dynaForm.getVar());
+
+ if (isTable(layoutComponent))
+ {
+ guiBuilder.setNewComponentListener(new AddComponentToTable(layoutComponent));
+ }
+ else
+ {
+ guiBuilder.setNewComponentListener(new AddComponentSimple(layoutComponent));
+ }
String valueBindingPrefix = getValueBindingPrefix(dynaForm, layoutComponent);
if (valueBindingPrefix == null)
@@ -256,9 +256,9 @@
}
guiBuilder.setBackingEntityPrefix(valueBindingPrefix);
- slipstream.setGuiBuilder(guiBuilder);
- slipstream.process();
- }
+ slipstream.setGuiBuilder(guiBuilder);
+ slipstream.process();
+ }
private boolean isTable(UIComponent layoutComponent)
{
@@ -277,86 +277,86 @@
}
private MetaData extractMetaData(final DynaForm dynaForm)
- {
- MetaData metaData = new MetaData();
+ {
+ MetaData metaData = new MetaData();
- try
- {
- // lookup which fields to process
- new JsfRequestFieldExtractor().getMetaData(metaData, dynaForm);
-
- if (dynaForm.isExclusiveFields())
- {
- // the same as above, but keep their ordering and some additional metadata
- new JsfExclusiveExtractor().getMetaData(metaData, dynaForm);
- metaData.setLockFields(true);
- }
-
- // use the users extractor
- dynaForm.getExtractor().getMetaData(metaData, dynaForm.getConfiguration().getEntity());
-
- // processs the jsf stuff
- new JsfExtractor().getMetaData(metaData, dynaForm);
-
- }
- finally
- {
- metaData.setLockFields(false);
- }
-
- return metaData;
- }
-
- protected JsfGuiBuilder createGuiBuilder(final FacesContext facesContext)
- {
- return JsfGuiBuilderFactory.create(facesContext);
- }
-
- /**
- * check if we already added components to the layout component.<br />
- *
- * if this is the case then:
- * <ul>
- * <li>keep them cached and avoid readd</li>
- * <li><strike>in development mode: remove the components</strike></li>
- * <li><strike>in production mode: keep them cached</strike></li>
- * </ul>
- *
- * TODO: need to figure out whats the best way to recreate the components
- * @return true if we have to add our components again
- */
- protected boolean processPreviouslyAdded(FacesContext context,
- UIComponent root)
- {
- List rootComponentChildren = root.getChildren();
- if (rootComponentChildren != null)
- {
- for (Object component : rootComponentChildren)
- {
- UIComponent child = (UIComponent) component;
- if (Boolean.TRUE.equals(child.getAttributes().get(
- DynaForm.DYNA_FORM_CREATED)))
- {
- return false;
- }
-
- if (!processPreviouslyAdded(context, child))
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
- @Override
- public void encodeChildren(FacesContext context, UIComponent component)
- throws IOException
- {
- // TODO: remove this (and maybe the method at all) afer myfaces > 1.1.1
- // is out ==>
- ComponentUtils.renderChildren(context, component);
- // TODO: remove this afer myfaces > 1.1.1 is out <==
- }
+ try
+ {
+ // lookup which fields to process
+ new JsfRequestFieldExtractor().getMetaData(metaData, dynaForm);
+
+ if (dynaForm.isExclusiveFields())
+ {
+ // the same as above, but keep their ordering and some additional metadata
+ new JsfExclusiveExtractor().getMetaData(metaData, dynaForm);
+ metaData.setLockFields(true);
+ }
+
+ // use the users extractor
+ dynaForm.getExtractor().getMetaData(metaData, dynaForm.getConfiguration().getEntity());
+
+ // processs the jsf stuff
+ new JsfExtractor().getMetaData(metaData, dynaForm);
+
+ }
+ finally
+ {
+ metaData.setLockFields(false);
+ }
+
+ return metaData;
+ }
+
+ protected JsfGuiBuilder createGuiBuilder(final FacesContext facesContext)
+ {
+ return JsfGuiBuilderFactory.create(facesContext);
+ }
+
+ /**
+ * check if we already added components to the layout component.<br />
+ *
+ * if this is the case then:
+ * <ul>
+ * <li>keep them cached and avoid readd</li>
+ * <li><strike>in development mode: remove the components</strike></li>
+ * <li><strike>in production mode: keep them cached</strike></li>
+ * </ul>
+ *
+ * TODO: need to figure out whats the best way to recreate the components
+ * @return true if we have to add our components again
+ */
+ protected boolean processPreviouslyAdded(FacesContext context,
+ UIComponent root)
+ {
+ List rootComponentChildren = root.getChildren();
+ if (rootComponentChildren != null)
+ {
+ for (Object component : rootComponentChildren)
+ {
+ UIComponent child = (UIComponent) component;
+ if (Boolean.TRUE.equals(child.getAttributes().get(
+ DynaForm.DYNA_FORM_CREATED)))
+ {
+ return false;
+ }
+
+ if (!processPreviouslyAdded(context, child))
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public void encodeChildren(FacesContext context, UIComponent component)
+ throws IOException
+ {
+ // TODO: remove this (and maybe the method at all) afer myfaces > 1.1.1
+ // is out ==>
+ ComponentUtils.renderChildren(context, component);
+ // TODO: remove this afer myfaces > 1.1.1 is out <==
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaFormTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaFormTag.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaFormTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/component/dynaForm/DynaFormTag.java Thu Jul 3 14:58:05 2008
@@ -24,115 +24,115 @@
public class DynaFormTag extends UIComponentBodyTagBase
{
- private String uri;
- private String var;
+ private String uri;
+ private String var;
private String valueBindingPrefix;
- private String displayOnly;
- private String bundle;
- private String exclusiveFields;
+ private String displayOnly;
+ private String bundle;
+ private String exclusiveFields;
public void release()
- {
- super.release();
+ {
+ super.release();
- uri = null;
- var = null;
- displayOnly = null;
- bundle = null;
- exclusiveFields = null;
+ uri = null;
+ var = null;
+ displayOnly = null;
+ bundle = null;
+ exclusiveFields = null;
valueBindingPrefix = null;
}
- protected void setProperties(UIComponent component)
- {
- super.setProperties(component);
- setStringProperty(component, "uri", uri);
- setStringProperty(component, "var", var);
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setStringProperty(component, "uri", uri);
+ setStringProperty(component, "var", var);
setStringProperty(component, "valueBindingPrefix", valueBindingPrefix);
setBooleanProperty(component, "displayOnly", displayOnly);
- setStringProperty(component, "bundle", bundle);
- setBooleanProperty(component, "exclusiveFields", exclusiveFields);
- }
-
- /**
- * @see DynaForm#setUri(String)
- */
- public String getUri()
- {
- return uri;
- }
-
- /**
- * @see DynaForm#setUri(String)
- */
- public void setUri(String uri)
- {
- this.uri = uri;
- }
-
- /**
- * @see DynaForm#setVar(String)
- */
- public String getVar()
- {
- return var;
- }
-
- /**
- * @see DynaForm#setVar(String)
- */
- public void setVar(String var)
- {
- this.var = var;
- }
-
- /**
- * @see DynaForm#setDisplayOnly(boolean)
- */
- public String getDisplayOnly()
- {
- return displayOnly;
- }
-
- /**
- * @see DynaForm#setDisplayOnly(boolean)
- */
- public void setDisplayOnly(String displayOnly)
- {
- this.displayOnly = displayOnly;
- }
-
- /**
- * @see DynaForm#setBundle(String)
- */
- public String getBundle()
- {
- return bundle;
- }
-
- /**
- * @see DynaForm#setBundle(String)
- */
- public void setBundle(String bundle)
- {
- this.bundle = bundle;
- }
-
- /**
- * @see DynaForm#setExclusiveFields(boolean)
- */
- public String getExclusiveFields()
- {
- return exclusiveFields;
- }
-
- /**
- * @see DynaForm#setExclusiveFields(boolean)
- */
- public void setExclusiveFields(String exclusiveFields)
- {
- this.exclusiveFields = exclusiveFields;
- }
+ setStringProperty(component, "bundle", bundle);
+ setBooleanProperty(component, "exclusiveFields", exclusiveFields);
+ }
+
+ /**
+ * @see DynaForm#setUri(String)
+ */
+ public String getUri()
+ {
+ return uri;
+ }
+
+ /**
+ * @see DynaForm#setUri(String)
+ */
+ public void setUri(String uri)
+ {
+ this.uri = uri;
+ }
+
+ /**
+ * @see DynaForm#setVar(String)
+ */
+ public String getVar()
+ {
+ return var;
+ }
+
+ /**
+ * @see DynaForm#setVar(String)
+ */
+ public void setVar(String var)
+ {
+ this.var = var;
+ }
+
+ /**
+ * @see DynaForm#setDisplayOnly(boolean)
+ */
+ public String getDisplayOnly()
+ {
+ return displayOnly;
+ }
+
+ /**
+ * @see DynaForm#setDisplayOnly(boolean)
+ */
+ public void setDisplayOnly(String displayOnly)
+ {
+ this.displayOnly = displayOnly;
+ }
+
+ /**
+ * @see DynaForm#setBundle(String)
+ */
+ public String getBundle()
+ {
+ return bundle;
+ }
+
+ /**
+ * @see DynaForm#setBundle(String)
+ */
+ public void setBundle(String bundle)
+ {
+ this.bundle = bundle;
+ }
+
+ /**
+ * @see DynaForm#setExclusiveFields(boolean)
+ */
+ public String getExclusiveFields()
+ {
+ return exclusiveFields;
+ }
+
+ /**
+ * @see DynaForm#setExclusiveFields(boolean)
+ */
+ public void setExclusiveFields(String exclusiveFields)
+ {
+ this.exclusiveFields = exclusiveFields;
+ }
/**
* @see DynaForm#setValueBindingPrefix(String)
@@ -151,12 +151,12 @@
}
public String getComponentType()
- {
- return DynaForm.COMPONENT_TYPE;
- }
-
- public String getRendererType()
- {
- return DynaForm.DEFAULT_RENDERER_TYPE;
- }
+ {
+ return DynaForm.COMPONENT_TYPE;
+ }
+
+ public String getRendererType()
+ {
+ return DynaForm.DEFAULT_RENDERER_TYPE;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/ComponentEnum.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/ComponentEnum.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/ComponentEnum.java (original)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/ComponentEnum.java Thu Jul 3 14:58:05 2008
@@ -20,12 +20,12 @@
public enum ComponentEnum
{
- Automatic,
- OutputText,
- InputText,
- InputDate,
- SelectOneMenu,
- // SelectSearchMenu,
- InputNumber,
- InputBoolean
+ Automatic,
+ OutputText,
+ InputText,
+ InputDate,
+ SelectOneMenu,
+ // SelectSearchMenu,
+ InputNumber,
+ InputBoolean
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/GuiBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/GuiBuilder.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/GuiBuilder.java (original)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/GuiBuilder.java Thu Jul 3 14:58:05 2008
@@ -31,193 +31,193 @@
*/
public abstract class GuiBuilder
{
- private boolean displayOnly;
- private Map labelBundle;
+ private boolean displayOnly;
+ private Map labelBundle;
- /**
- * @see #setDisplayOnly(boolean)
- */
- public boolean isDisplayOnly()
- {
- return displayOnly;
- }
-
- /**
- * set if the guiBuilder should build a read only form only
- */
- public void setDisplayOnly(boolean displayOnly)
- {
- this.displayOnly = displayOnly;
- }
-
- /**
- * @see #setLabelBundle(Map)
- */
- public Map getLabelBundle()
- {
- return labelBundle;
- }
-
- /**
- * the bundle to use with labels
- */
- public void setLabelBundle(Map labelBundle)
- {
- this.labelBundle = labelBundle;
- }
-
- /**
- * output text using the field as value provider
- */
- public abstract void createOutputText(FieldInterface field);
-
- /**
- * input field
- */
- public abstract void createInputText(FieldInterface field);
-
- /**
- * input date
- */
- public abstract void createInputDate(FieldInterface field);
-
- /**
- * select one menu
- */
- public abstract void createSelectOneMenu(FieldInterface field);
-
- /**
- * enter a number
- */
- public abstract void createInputNumber(FieldInterface field);
-
- /**
- * select a boolean
- */
- public abstract void createInputBoolean(FieldInterface field);
-
- /**
- * search for component
- */
- public abstract void createSearchFor(FieldInterface field);
-
- /**
- * search for component
- */
- public abstract void createSearchForSelectMenu(FieldInterface field);
-
- // public abstract void createSearchForSelectMenu(FieldInterface field);
-
- /**
- * this is when the user passed in a component to use for the this field
- */
- public abstract void createNative(FieldInterface field);
-
- /**
- * actuallly build the fields gui component
- */
- protected boolean buildField(FieldInterface field)
- {
- Class fieldType = field.getType();
-
- if (field.getWantedComponent() != null)
- {
- createNative(field);
- return true;
- }
-
- if (!field.getWantedComponentType().equals(ComponentEnum.Automatic))
- {
- switch(field.getWantedComponentType())
- {
- case OutputText:
- createOutputText(field);
- return true;
-
- case InputText:
- createInputText(field);
- return true;
-
- case InputDate:
- createInputDate(field);
- return true;
-
- case SelectOneMenu:
- if (RelationType.MANY_TO_ONE.equals(field.getRelationType()))
- {
- createSearchForSelectMenu(field);
- }
- else
- {
- // TODO: will not work now
- createSelectOneMenu(field);
- }
- return true;
-
- /*
- case SelectSearchMenu:
- createSearchForSelectMenu(field);
- return true;
- */
-
- case InputNumber:
- createInputNumber(field);
- return true;
-
- case InputBoolean:
- createInputBoolean(field);
- return true;
- }
- }
-
- if (Boolean.TRUE.equals(field.getDisplayOnly()))
- {
- createOutputText(field);
- return true;
- }
-
- if (field.getAllowedSelections() != null)
- {
- createSelectOneMenu(field);
- return true;
- }
-
- if (RelationType.MANY_TO_ONE.equals(field.getRelationType()))
- {
- createSearchFor(field);
- return true;
- }
-
- if (fieldType == null)
- {
- throw new IllegalArgumentException("No type for field '" + field.getName() + "' detected.");
- }
-
- if (Date.class.isAssignableFrom(fieldType))
- {
- createInputDate(field);
- return true;
- }
-
- TypeInfos.Info typeInfo = TypeInfos.getInfo(fieldType);
- if (typeInfo != null && typeInfo.isNumber())
- {
- createInputNumber(field);
- return true;
- }
-
- if (String.class.isAssignableFrom(fieldType))
- {
- createInputText(field);
- return true;
- }
-
- if (Boolean.class.isAssignableFrom(fieldType) || boolean.class.equals(fieldType))
- {
- createInputBoolean(field);
- return true;
- }
+ /**
+ * @see #setDisplayOnly(boolean)
+ */
+ public boolean isDisplayOnly()
+ {
+ return displayOnly;
+ }
+
+ /**
+ * set if the guiBuilder should build a read only form only
+ */
+ public void setDisplayOnly(boolean displayOnly)
+ {
+ this.displayOnly = displayOnly;
+ }
+
+ /**
+ * @see #setLabelBundle(Map)
+ */
+ public Map getLabelBundle()
+ {
+ return labelBundle;
+ }
+
+ /**
+ * the bundle to use with labels
+ */
+ public void setLabelBundle(Map labelBundle)
+ {
+ this.labelBundle = labelBundle;
+ }
+
+ /**
+ * output text using the field as value provider
+ */
+ public abstract void createOutputText(FieldInterface field);
+
+ /**
+ * input field
+ */
+ public abstract void createInputText(FieldInterface field);
+
+ /**
+ * input date
+ */
+ public abstract void createInputDate(FieldInterface field);
+
+ /**
+ * select one menu
+ */
+ public abstract void createSelectOneMenu(FieldInterface field);
+
+ /**
+ * enter a number
+ */
+ public abstract void createInputNumber(FieldInterface field);
+
+ /**
+ * select a boolean
+ */
+ public abstract void createInputBoolean(FieldInterface field);
+
+ /**
+ * search for component
+ */
+ public abstract void createSearchFor(FieldInterface field);
+
+ /**
+ * search for component
+ */
+ public abstract void createSearchForSelectMenu(FieldInterface field);
+
+ // public abstract void createSearchForSelectMenu(FieldInterface field);
+
+ /**
+ * this is when the user passed in a component to use for the this field
+ */
+ public abstract void createNative(FieldInterface field);
+
+ /**
+ * actuallly build the fields gui component
+ */
+ protected boolean buildField(FieldInterface field)
+ {
+ Class fieldType = field.getType();
+
+ if (field.getWantedComponent() != null)
+ {
+ createNative(field);
+ return true;
+ }
+
+ if (!field.getWantedComponentType().equals(ComponentEnum.Automatic))
+ {
+ switch(field.getWantedComponentType())
+ {
+ case OutputText:
+ createOutputText(field);
+ return true;
+
+ case InputText:
+ createInputText(field);
+ return true;
+
+ case InputDate:
+ createInputDate(field);
+ return true;
+
+ case SelectOneMenu:
+ if (RelationType.MANY_TO_ONE.equals(field.getRelationType()))
+ {
+ createSearchForSelectMenu(field);
+ }
+ else
+ {
+ // TODO: will not work now
+ createSelectOneMenu(field);
+ }
+ return true;
+
+ /*
+ case SelectSearchMenu:
+ createSearchForSelectMenu(field);
+ return true;
+ */
+
+ case InputNumber:
+ createInputNumber(field);
+ return true;
+
+ case InputBoolean:
+ createInputBoolean(field);
+ return true;
+ }
+ }
+
+ if (Boolean.TRUE.equals(field.getDisplayOnly()))
+ {
+ createOutputText(field);
+ return true;
+ }
+
+ if (field.getAllowedSelections() != null)
+ {
+ createSelectOneMenu(field);
+ return true;
+ }
+
+ if (RelationType.MANY_TO_ONE.equals(field.getRelationType()))
+ {
+ createSearchFor(field);
+ return true;
+ }
+
+ if (fieldType == null)
+ {
+ throw new IllegalArgumentException("No type for field '" + field.getName() + "' detected.");
+ }
+
+ if (Date.class.isAssignableFrom(fieldType))
+ {
+ createInputDate(field);
+ return true;
+ }
+
+ TypeInfos.Info typeInfo = TypeInfos.getInfo(fieldType);
+ if (typeInfo != null && typeInfo.isNumber())
+ {
+ createInputNumber(field);
+ return true;
+ }
+
+ if (String.class.isAssignableFrom(fieldType))
+ {
+ createInputText(field);
+ return true;
+ }
+
+ if (Boolean.class.isAssignableFrom(fieldType) || boolean.class.equals(fieldType))
+ {
+ createInputBoolean(field);
+ return true;
+ }
- return false;
- }
+ return false;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/Slipstream.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/Slipstream.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/Slipstream.java (original)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/guiBuilder/Slipstream.java Thu Jul 3 14:58:05 2008
@@ -29,74 +29,74 @@
*/
public class Slipstream
{
- private boolean displayOnly;
- private MetaDataInterface modelMetaData;
- private GuiBuilder guiBuilder;
- private Map labelBundle;
-
- public Slipstream()
- {
- }
-
- public boolean isDisplayOnly()
- {
- return displayOnly;
- }
-
- public void setDisplayOnly(boolean displayOnly)
- {
- this.displayOnly = displayOnly;
- }
-
- public MetaDataInterface getModelMetaData()
- {
- return modelMetaData;
- }
-
- public void setModelMetaData(MetaDataInterface modelMetaData)
- {
- this.modelMetaData = modelMetaData;
- }
-
- public GuiBuilder getGuiBuilder()
- {
- return guiBuilder;
- }
-
- public void setGuiBuilder(GuiBuilder guiBuilder)
- {
- this.guiBuilder = guiBuilder;
- }
-
- public Map getLabelBundle()
- {
- return labelBundle;
- }
-
- public void setLabelBundle(Map labelBundle)
- {
- this.labelBundle = labelBundle;
- }
-
- public void process()
- {
- configureGuiBuilder();
-
- MetaDataInterface metaData = modelMetaData;
- Iterator<String> iterFieldNames = metaData.iterFieldNames();
- while (iterFieldNames.hasNext())
- {
- String fieldName = iterFieldNames.next();
- FieldInterface field = modelMetaData.getField(fieldName);
-
- guiBuilder.buildField(field);
- }
- }
-
- protected void configureGuiBuilder()
- {
- guiBuilder.setDisplayOnly(isDisplayOnly());
- guiBuilder.setLabelBundle(getLabelBundle());
- }
+ private boolean displayOnly;
+ private MetaDataInterface modelMetaData;
+ private GuiBuilder guiBuilder;
+ private Map labelBundle;
+
+ public Slipstream()
+ {
+ }
+
+ public boolean isDisplayOnly()
+ {
+ return displayOnly;
+ }
+
+ public void setDisplayOnly(boolean displayOnly)
+ {
+ this.displayOnly = displayOnly;
+ }
+
+ public MetaDataInterface getModelMetaData()
+ {
+ return modelMetaData;
+ }
+
+ public void setModelMetaData(MetaDataInterface modelMetaData)
+ {
+ this.modelMetaData = modelMetaData;
+ }
+
+ public GuiBuilder getGuiBuilder()
+ {
+ return guiBuilder;
+ }
+
+ public void setGuiBuilder(GuiBuilder guiBuilder)
+ {
+ this.guiBuilder = guiBuilder;
+ }
+
+ public Map getLabelBundle()
+ {
+ return labelBundle;
+ }
+
+ public void setLabelBundle(Map labelBundle)
+ {
+ this.labelBundle = labelBundle;
+ }
+
+ public void process()
+ {
+ configureGuiBuilder();
+
+ MetaDataInterface metaData = modelMetaData;
+ Iterator<String> iterFieldNames = metaData.iterFieldNames();
+ while (iterFieldNames.hasNext())
+ {
+ String fieldName = iterFieldNames.next();
+ FieldInterface field = modelMetaData.getField(fieldName);
+
+ guiBuilder.buildField(field);
+ }
+ }
+
+ protected void configureGuiBuilder()
+ {
+ guiBuilder.setDisplayOnly(isDisplayOnly());
+ guiBuilder.setLabelBundle(getLabelBundle());
+ }
}