QeelwaEtech / omnifaces

Automatically exported from code.google.com/p/omnifaces
0 stars 1 forks source link

SelectItemsIndexConverter#getAsString should return an empty string on a f:selectItem with noSelectionOption="true" set #181

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I've a problem using JSF code like this:

<h:selectOneMenu value="#{testBean.prop}" 
converter="omnifaces.SelectItemsIndexConverter">
  <f:selectItem itemLabel="#{messages.choose_one}" noSelectionOption="true" />
  <f:selectItems value="#{allProps}" var="p" itemLabel="#{p.name}" />                        </h:selectOneMenu>

This gets rendered as:

<select size="1" name="...">
  <option selected="selected">Choose one</option>
  <option value="0">test1</option>
</select>

Submitting the enclosing form will fail with a validation error because 
SelectItemsIndexConverter#getAsObject() is called with the full item *label* 
"Choose one" if I don't select any option.

This is on JBoss AS-7.1.1 using Mojarra 2.1.7-jbossorg-1.

I've verified that returning an empty string as per JSF-spec 
(https://javaserverfaces.java.net/nonav/docs/2.1/javadocs/javax/faces/convert/Co
nverter.html#getAsString(javax.faces.context.FacesContext, 
javax.faces.component.UIComponent, java.lang.Object)) fixes the issue by 
rendering an empty value attribute on the noSelectionOption.

Original issue reported on code.google.com by matti.bi...@gmail.com on 30 May 2013 at 10:01

GoogleCodeExporter commented 9 years ago

Original comment by balusc on 30 May 2013 at 4:15

GoogleCodeExporter commented 9 years ago
Fixed: 
https://code.google.com/p/omnifaces/source/detail?r=2bc201bc84d12f1ff950c3982179
6c3c8a3a92b2

Thank you for reporting.

Original comment by balusc on 30 May 2013 at 4:18