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 2007/11/05 13:42:19 UTC
svn commit: r591974 -
/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/GuiBuilder.java
Author: skitching
Date: Mon Nov 5 04:42:19 2007
New Revision: 591974
URL: http://svn.apache.org/viewvc?rev=591974&view=rev
Log:
Add translateText method.
Rename a couple of methods for clarity.
Modified:
myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/GuiBuilder.java
Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/GuiBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/GuiBuilder.java?rev=591974&r1=591973&r2=591974&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/GuiBuilder.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/GuiBuilder.java Mon Nov 5 04:42:19 2007
@@ -26,8 +26,17 @@
import java.util.Map;
/**
- * The interface to the gui builder which creates all needed gui elements.<br />
- * You have implement each of them.
+ * A factory for creating gui-framework-specific representations of
+ * data to be displayed to a user.
+ * <p>
+ * A concrete subclass of this type is needed for each specific
+ * UI framework. Component-based frameworks (such as JSF) may create
+ * component objects and add them to a "component tree", while other
+ * frameworks may simply write data to the current response stream.
+ * <p>
+ * This base class defines the abstract factory methods, and also
+ * provides a number of utility classes for the concrete subclasses
+ * to use.
*/
public abstract class GuiBuilder
{
@@ -36,16 +45,17 @@
private Map labelBundle;
/**
- * check if this field should be rendered display only
+ * Returns true if this field should be rendered display only.
*/
- public boolean isDisplayOnly(FieldInterface field)
+ public boolean isFieldDisplayOnly(FieldInterface field)
{
return displayOnly || (isIdAsDisplayOnly() && field.isId());
}
- /**
- * set if the guiBuilder should build a read only form only
+
+ /**
+ * Set to true if the guiBuilder should build a read-only form only.
*/
- public void setDisplayOnly(boolean displayOnly)
+ public void setFormDisplayOnly(boolean displayOnly)
{
this.displayOnly = displayOnly;
}
@@ -75,7 +85,12 @@
}
/**
- * the bundle to use with labels
+ * The resource bundle to be used when translating field names into
+ * text labels.
+ * <p>
+ * A labelBundle is optional; if not specified then the field name will
+ * be used as the label. In addition, if a field-name is not defined in
+ * the resource bundle then the raw field-name will also be used.
*/
public void setLabelBundle(Map labelBundle)
{
@@ -83,7 +98,7 @@
}
/**
- * output text using the field as value provider
+ * Output text using the field as value provider.
*/
public abstract void createOutputText(FieldInterface field);
@@ -235,5 +250,33 @@
}
return false;
+ }
+
+ /**
+ * Localise a text string using the resource-bundle specified for the dynaform.
+ * <p>
+ * If the key is null, or there is no resource-bundle, or there is no entry in
+ * the resource bundle for the specified key, then return the dflt string.
+ */
+ protected String translateText(String key, String dflt)
+ {
+ if (key == null)
+ {
+ return dflt;
+ }
+
+ Map bundle = getLabelBundle();
+ if (bundle == null)
+ {
+ return dflt;
+ }
+
+ Object val = bundle.get(key);
+ if (val != null)
+ {
+ return val.toString();
+ }
+
+ return dflt;
}
}