[jboss-cvs] jboss-seam/src/ui/org/jboss/seam/ui ...
Peter Muir
peter at bleepbleep.org.uk
Sat Mar 17 11:30:49 EDT 2007
User: pmuir
Date: 07/03/17 11:30:49
Modified: src/ui/org/jboss/seam/ui UISelectItems.java
Log:
JBSEAM-1036
Revision Changes Path
1.13 +37 -33 jboss-seam/src/ui/org/jboss/seam/ui/UISelectItems.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UISelectItems.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/UISelectItems.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- UISelectItems.java 10 Mar 2007 19:07:11 -0000 1.12
+++ UISelectItems.java 17 Mar 2007 15:30:49 -0000 1.13
@@ -58,7 +58,8 @@
}
else
{
- return getString("noSelectionLabel");
+ ValueBinding vb = getValueBinding("noSelectionLabel");
+ return vb == null ? null : JSF.getStringValue( getFacesContext(), vb);
}
}
@@ -75,8 +76,9 @@
}
else
{
- Boolean value = getBoolean("hideNoSelectionLabel");
- return value == null ? false : value;
+ ValueBinding vb = getValueBinding("hideNoSelectionLabel");
+ Boolean b = vb == null ? false : JSF.getBooleanValue(getFacesContext(), vb);
+ return b == null ? false : b;
}
}
@@ -103,7 +105,8 @@
}
else
{
- return getString("label");
+ ValueBinding vb = getValueBinding("label");
+ return vb == null ? null : JSF.getStringValue( getFacesContext(), vb);
}
}
@@ -120,8 +123,9 @@
}
else
{
- Boolean value = getBoolean("disabled");
- return value != null ? value : false;
+ ValueBinding vb = getValueBinding("disabled");
+ Boolean b = vb == null ? false : JSF.getBooleanValue(getFacesContext(), vb);
+ return b == null ? false : b;
}
}
@@ -156,32 +160,6 @@
return values;
}
- private String getString(String localName)
- {
- ValueBinding vb = getValueBinding(localName);
- if (vb == null)
- {
- return null;
- }
- else
- {
- return vb.getValue(getFacesContext()).toString();
- }
- }
-
- private Boolean getBoolean(String localName)
- {
- String string = getString(localName);
- if (string != null)
- {
- return Boolean.valueOf(string);
- }
- else
- {
- return null;
- }
- }
-
@Override
public Object getValue()
{
@@ -250,7 +228,33 @@
private javax.faces.model.SelectItem noSelectionLabel()
{
- if (getNoSelectionLabel() != null && !(isHideNoSelectionLabel() && getParentValue() != null))
+ boolean show = false;
+ /*
+ * This is a slight hack. If you do an EL expresison like this (to hide the label)
+ *
+ * noSelectionLabel="#{x eq y ? 'Please Select' : null}"
+ *
+ * then, if x != y, EL will return an empty String, not null, so we work around that, with the side effect
+ * that if the result of the EL expression is an empty String, then the label will be hidden.
+ */
+ if (noSelectionLabel != null && !(isHideNoSelectionLabel() && getParentValue() != null))
+ {
+ /*
+ * Here, the user has specfied a noSelectionLabel (may be an empty string), and, if hideNoSelectionLabel
+ * is set, then, if a value is selected, then the label is hidden
+ */
+ show = true;
+ }
+ else if (getNoSelectionLabel() != null && !"".equals(getNoSelectionLabel()) && !(isHideNoSelectionLabel() && getParentValue() != null))
+ {
+ /*
+ * Here, the user has used an EL expression as the noSelectionLabel. In this case, an empty string is
+ * indicates that the label should be hidden.
+ */
+ show = true;
+ }
+
+ if (show)
{
NullableSelectItem s = new NullableSelectItem(NO_SELECTION_VALUE, getNoSelectionLabel());
ConverterChain converterChain = new ConverterChain(this.getParent());
More information about the jboss-cvs-commits
mailing list