Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Invalid
-
Affects Version/s: EE-1.8.2.GA_P04
-
Fix Version/s: EE-1.8.2.GA_P05
-
Component/s: ICE-Components
-
Labels:None
-
Environment:All
-
Assignee Priority:P1
-
Workaround Exists:Yes
-
Workaround Description:HideDon't use an empty string, instead use any other sentinel value. A space works:
<f:selectItem itemValue=" " itemLabel="-" />
private String a = " ";
ShowDon't use an empty string, instead use any other sentinel value. A space works: <f:selectItem itemValue=" " itemLabel="-" /> private String a = " ";
Description
When the value change listener is called, the getNewValue() method returns null instead of an empty string which it is initialized to.
-
Hide
- Case11350Example.war
- 6.66 MB
- Arran Mccullough
-
- META-INF/MANIFEST.MF 0.1 kB
- META-INF/context.xml 0.1 kB
- WEB-INF/classes/com/.../example/Item.class 0.3 kB
- WEB-INF/classes/.../example/TestBean.class 1 kB
- WEB-INF/faces-config.xml 0.8 kB
- WEB-INF/lib/FastInfoset.jar 285 kB
- WEB-INF/lib/backport-util-concurrent.jar 319 kB
- WEB-INF/lib/commons-beanutils.jar 226 kB
- WEB-INF/lib/commons-collections.jar 558 kB
- WEB-INF/lib/commons-digester.jar 140 kB
- WEB-INF/lib/commons-discovery.jar 75 kB
- WEB-INF/lib/commons-fileupload.jar 56 kB
- WEB-INF/lib/commons-lang.jar 240 kB
- WEB-INF/lib/commons-logging.jar 52 kB
- WEB-INF/lib/icefaces-comps.jar 1.76 MB
- WEB-INF/lib/icefaces-facelets.jar 596 kB
- WEB-INF/lib/icefaces.jar 1.23 MB
- WEB-INF/lib/jsf-api-1.2.jar 355 kB
- WEB-INF/lib/jsf-impl-1.2.jar 837 kB
- WEB-INF/web.xml 4 kB
- welcomeICEfaces.xhtml 1 kB
-
- Case11350Example.zip
- 19 kB
- Arran Mccullough
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
It looks like MenuRenderer.getConvertedValue(...) converts an empty string submitted value to a null. This method is called during validation.
if (uiComponent instanceof UISelectOne) {
if (newSubmittedValue == null || "".equals(newSubmittedValue))
else {
.....
I don't know what is the expected behavior but it seems to me that empty strings should not be changed to null values since the MenuRenderer is already using empty strings in its decode method.
Changing MenuRenderer.getConvertedValue(...) to avoid converting empty strings solves this issue.
With HTML forms, a lack of data entered is frequently submitted as:
form_field_name=
which means that it doesn't differentiate between no input and a string with no length. With select + option elements, we have the same issue where when an option has selected=selected, then the select is submitted as it's name = the selected option's value. If that option happens to have a value of a string with no length, then it's indistinguishable from no selection happening. As such, a string with no length is effectively a reserved sentinel value for no selection, and it's not proper application usage to take that value and re-use it for something else. In this case, the application is using it to indicate a selection of an option which it internally deems as a non-user-choice. We need to take care to avoid confusing non-selection and non-user-choice.
To fix this, we need to make use of another sentinel value to indicate this non-user-choice. Anything will do, and I have tested that a space works fine. I changed the selectItem thusly:
<f:selectItem itemValue=" " itemLabel="-" />
And also, we need to change what the bean property is initialised to, or else we'll still get a single errant ValueChangeEvent.
private String a = " ";
Attached Test case that shows issue.
Steps: