Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.5.1
-
Component/s: ICE-Components
-
Labels:None
-
Environment:Operating System: Windows XP
Platform: PC
Description
ice:selectOneMenu used to select the U.S. State. Currently, it defaults to
the first state, but we would like it to have an initial value of nothing with
the required="true" attribute on the component to force someone to select a
state.
At this point in time, adding an initial SelectItem with the value of an empty
String will not fire the required="true" validator and initializing the first
SelectItem to nothing will give it a null value and fire a ValidationError:
Value is not valid.
For testing purposes, you can add an initial entry with an empty String to the
application by going to the Criteria class, removing the current
initialization of the US_STATE_LIST and adding these two lines to the static
block:
US_STATE_LIST = new ArrayList(LocationLists.getUsStatesListSize()+1);
US_STATE_LIST.add(0,new SelectItem(""));
What we would like to do is add an empty initial SelectItem that would then
fire the required="true" validator on the component. Please refer to ICE-873
which was previously supposed to have resolved this issue.
-
Hide
- sample-icefaces-sun-portlet.war
- 4.60 MB
- Neil Griffin
-
- META-INF/MANIFEST.MF 0.1 kB
- Help.jspx 2 kB
- JobApplication.jspx 8 kB
- META-INF/context.xml 2 kB
- WEB-INF/classes/Help.properties 1 kB
- WEB-INF/.../JobApplication.properties 2 kB
- WEB-INF/classes/Language.properties 2 kB
- WEB-INF/classes/.../ResourceBundleUtil.class 2 kB
- WEB-INF/.../FileUploadManagedBean.class 6 kB
- WEB-INF/classes/.../jsf/ActionOutcomes.class 0.4 kB
- WEB-INF/.../EmailAddressValidator.class 3 kB
- WEB-INF/classes/.../FacesMessageUtil.class 4 kB
- WEB-INF/.../PhoneNumberConverter.class 3 kB
- WEB-INF/.../PortalUserManagedBean.class 1 kB
- WEB-INF/.../SelectItemAscendingComparator.class 0.8 kB
- WEB-INF/classes/.../jsf/SelectItemList.class 2 kB
- WEB-INF/classes/.../JobApplication.class 7 kB
- WEB-INF/.../commons-logging.properties 1 kB
- WEB-INF/classes/log4j.properties 2 kB
- WEB-INF/classes/log4j.xml 14 kB
- WEB-INF/faces-config.xml 3 kB
- WEB-INF/lib/backport-util-concurrent.jar 343 kB
- WEB-INF/lib/commons-beanutils.jar 184 kB
- WEB-INF/lib/commons-collections.jar 546 kB
- WEB-INF/lib/commons-digester.jar 107 kB
- WEB-INF/lib/commons-fileupload.jar 52 kB
- WEB-INF/lib/commons-lang.jar 240 kB
- WEB-INF/lib/commons-logging.jar 52 kB
- WEB-INF/lib/commons-validator.jar 136 kB
- WEB-INF/lib/el-api.jar 24 kB
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
I tested with the wells-fargo demo app and using "" as the value of the first item will fire the required validator. Not entering "" and leaving the item value as null will produce "null" as the first item in the UI.
However, after interacting with the other input components you are able to get through (without another "required" message showing up) without changing the selection to a valid value.
I just tried this again with the latest trunk and the required validator is not firing.
In my managed bean, I populate the list like this:
ArrayList listItems = new ArrayList();
listItems.add(new SelectItem("", "-- Select --");
The rendered HTML looks like this:
<option value="">-- Select --</option>
The required validator is not firing when I tab out of the field, and is not firing when I submit the form.
Please advise – Thanks!
Neil
Hi Brad and Neil,
I have checked-in a fix for the above issue, can you guys please verify if it has been fixed. revision 14237
Thanks,
I have tested this agains the wells-fargo demo and it appears to be working.
As Brad verified it. I am resolving this case.
I am experiencing the same problem with 1.5.3.
To be more precise, I'm building my select item list like this:
ArrayList<SelectItem> selectItemList = new ArrayList<SelectItem>();
selectItemList.add(new SelectItem("", "-- Select --"));
Now, this generates HTML that looks like this:
<select>
<option value="">-- Select --</option>
</select>
When the user does not select an item from the list (leaves it as "-- Select -
"), the com.icesoft.faces.component.ext.HtmlSelectOneMenu.validate(FacesContext facesContext) method calls the UIInput.getSubmittedValue() method, which, rather than returning an empty string (""), returns "- Select -"!!! This is the heart of the problem. Perhaps it is the ICEfaces partial-submit system passing "- Select --" as a request parameter value. I don't know.The reason why the "Validation Error: Value is not valid" message is happening, is because the HtmlSelectOneMenu.validate() sees "-- Select -
" instead of an empty string for the submitted value, and then lets the UISelectOne superclass handle it. The superclass does not see "- Select --" as a valid value in the selectitems, and so adds a javax.faces.component.UISelectOne.INVALID message to the validation error list, the English version of which is "Validation Error: Value is not valid"– Neil