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:44:13 UTC
svn commit: r591976 -
/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java
Author: skitching
Date: Mon Nov 5 04:44:12 2007
New Revision: 591976
URL: http://svn.apache.org/viewvc?rev=591976&view=rev
Log:
* Use new translateText method in baseclass. When a labelBundle is specified, but there is no translation for a propertyname, this now outputs the propertyname rather than a blank label.
* Remove a couple of unused constants.
Modified:
myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java
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=591976&r1=591975&r2=591976&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 Mon Nov 5 04:44:12 2007
@@ -66,13 +66,11 @@
import java.util.TreeMap;
/**
- * concrete gui builder which knows how to build JSF forms
+ * A concrete subclass of GuiBuilder which knows how to build JSF components and
+ * add them to the current component tree.
*/
public class JsfGuiBuilder extends GuiBuilder
{
- public static final String SEARCH_ENTITY_TYPE = "_ff_searchEntity";
- public static final String SEARCH_ENTITY_BINDING = "_ff_searchEntityBinding";
-
private FacesContext context;
private ELContext elcontext;
private NewComponentListener newComponentListener;
@@ -92,18 +90,6 @@
builderMap.put(elementType.getName(), builder);
}
- /*
- public String getBackingBeanPrefix()
- {
- return backingBeanPrefix;
- }
-
- public void setBackingBeanPrefix(String backingBeanPrefix)
- {
- this.backingBeanPrefix = backingBeanPrefix;
- }
- */
-
public String getBackingEntityPrefix()
{
return backingEntityPrefix;
@@ -156,7 +142,7 @@
public void createInputDate(FieldInterface field)
{
UIComponent cmp;
- if (!isDisplayOnly(field))
+ if (!isFieldDisplayOnly(field))
{
cmp = doCreateInputDate(field);
}
@@ -171,7 +157,7 @@
public void createInputText(FieldInterface field)
{
UIComponent cmp;
- if (!isDisplayOnly(field))
+ if (!isFieldDisplayOnly(field))
{
cmp = doCreateInputText(field);
}
@@ -186,7 +172,7 @@
public void createInputNumber(FieldInterface field)
{
UIComponent cmp;
- if (!isDisplayOnly(field))
+ if (!isFieldDisplayOnly(field))
{
cmp = doCreateInputNumber(field);
}
@@ -201,7 +187,7 @@
public void createInputBoolean(FieldInterface field)
{
UIComponent cmp;
- if (!isDisplayOnly(field))
+ if (!isFieldDisplayOnly(field))
{
cmp = doCreateInputBoolean(field);
}
@@ -216,7 +202,7 @@
public void createSelectOneMenu(FieldInterface field)
{
UIComponent cmp;
- if (!isDisplayOnly(field))
+ if (!isFieldDisplayOnly(field))
{
cmp = doCreateSelectOneMenu(field);
}
@@ -231,7 +217,7 @@
public void createSearchFor(FieldInterface field)
{
UIComponent cmp;
- if (!isDisplayOnly(field))
+ if (!isFieldDisplayOnly(field))
{
cmp = doCreateSearchFor(field);
}
@@ -246,7 +232,7 @@
public void createSearchForSelectMenu(FieldInterface field)
{
UIComponent cmp;
- if (!isDisplayOnly(field))
+ if (!isFieldDisplayOnly(field))
{
cmp = doCreateSearchForSelectMenu(field);
}
@@ -257,23 +243,6 @@
fireNewComponent(field, cmp);
}
- /*
- @Override
- public void createSearchForSelectMenu(FieldInterface field)
- {
- UIComponent cmp;
- if (!isDisplayOnly(field))
- {
- cmp = doCreateSearchForSelectMenu(field);
- }
- else
- {
- cmp = doCreateOutputText(field);
- }
- fireNewComponent(field, cmp);
- }
- */
-
@Override
public void createNative(FieldInterface field)
{
@@ -325,21 +294,33 @@
return cmp;
}
- public HtmlOutputLabel doCreateOutputLabel(String text)
+ /**
+ * Create an HtmlOutputLabel component, ie some text that
+ * specifically describes another input component.
+ * <p>
+ * The labelKey parameter is translated using a resource-bundle
+ * if possible. If no translation is available then the labelKey
+ * text is used directly.
+ */
+ public HtmlOutputLabel doCreateOutputLabel(String labelKey)
{
HtmlOutputLabel cmp = doCreateOutputLabelComponent();
initDefaults(cmp, null);
- if (getLabelBundle() != null)
- {
- cmp.setValue(getLabelBundle().get(text));
- }
- else
- {
- cmp.setValue(text);
- }
+ cmp.setValue(translateText(labelKey, labelKey));
return cmp;
}
+ /**
+ * Create an HtmlOutputText component, ie a component that displays
+ * a string.
+ * <p>
+ * Unlike doCreateOutputLabel, the parameter is the exact string to
+ * be displayed, not a key into a resource-bundle. This method is used
+ * to create components wrapping all sorts of strings, only some of
+ * which may be "translatable" via a resource bundle. If an output
+ * text component needs to contain translated text, then pass the
+ * translated value in as the parameter.
+ */
public HtmlOutputText doCreateOutputText(String text)
{
HtmlOutputText cmp = doCreateOutputTextComponent();
@@ -666,14 +647,7 @@
String labelKey = "SelectAll." + field.getName();
- if (getLabelBundle() != null && getLabelBundle().containsKey(labelKey))
- {
- item.setItemLabel((String) getLabelBundle().get(labelKey));
- }
- else
- {
- item.setItemLabel("");
- }
+ item.setItemLabel(translateText(labelKey, ""));
select.getChildren().add(item);
}
@@ -772,38 +746,36 @@
}
/**
- * create label for the given <code>labelText</code> and if possible
- * attach it to the <code>cmp</code>. <br />
- * If the component and none of its child is a UIInput then a simply
- * outputText is generated.
+ * Create a label for the specified component using the specified text.
+ * <p>
+ * If the component (or one of its children) is an input component, then an
+ * HtmlOutputLabel component is created, with the "for" attribute referencing
+ * the id of the input component. Otherwise a plain HtmlOutputText component
+ * is created.
*/
- public UIOutput createLabelFor(String labelText, UIComponent cmp)
+ public UIOutput createLabelFor(String labelKey, UIComponent cmp)
{
UIOutput labelCmp;
UIInput inputCmp = findInputComponent(cmp);
if (inputCmp != null)
{
- HtmlOutputLabel label = doCreateOutputLabel(labelText);
+ HtmlOutputLabel label = doCreateOutputLabel(labelKey);
label.setFor(cmp.getId());
labelCmp = label;
}
else
{
- if (getLabelBundle() != null)
- {
- labelCmp = doCreateOutputText((String) getLabelBundle().get(labelText));
- }
- else
- {
- labelCmp = doCreateOutputText(labelText);
- }
+ // method doCreateOutputText does not internally translate keys,
+ // so do so here.
+ String labelText = translateText(labelKey, labelKey);
+ labelCmp = doCreateOutputText(labelText);
}
return labelCmp;
}
/**
- * searches the first input component. e.g the one we can the label attach
- * to.
+ * Return the first UIInput component in the tree of components starting at
+ * the specified node (including the node itself).
*/
public UIInput findInputComponent(UIComponent cmp)
{
@@ -1104,14 +1076,8 @@
for (Selection selection : selections)
{
UISelectItem si = new UISelectItem();
- if (getLabelBundle() != null && selection.getLabel() != null)
- {
- si.setItemLabel((String) getLabelBundle().get(selection.getLabel()));
- }
- else
- {
- si.setItemLabel(selection.getLabel());
- }
+ String labelText = selection.getLabel();
+ si.setItemLabel(translateText(labelText, labelText));
si.setItemValue(selection.getValue());
cmp.getChildren().add(si);
}