Hi
I encountered a problem that seems like a bug in the JSF reference implementation 1.1.01
The UISelectMany is unable to set value to its valueBinding if the valueBinding is a list, and its selectItems value is a class other than String or primitive type.
In my JSF page, I have the following code:
<h:selectManyListbox value="#{form.Roles}">
<f:selectItems value="#{form.RoleItems}"/>
</h:selectManyListbox>
form is a session scope backing bean.
Role is a class as follows:
public class Role {
public Role(String role, int ranking, String description) {
....
}
}
The form backing bean has the following code :
public class FormBean {
private List roles = null;
public List getRoles() {
if (roles == null) roles = retrieveRole();
return roles;
}
public void setRoles(List values) {
roles = values;
}
}
The above codes look simple but it doesn't work. Whenever I submit the form, it will have a validation error.
Upon tracing in the JSF RI in debug mode, I discovered the following :
During the submit processing, the com.sun.faces.renderkit.html_basic.MenuRenderer. convertSelectManyValue function is called. In this function, it will detect that the valueBinding is of List type, then it will create a List of String representing the selected item values and return them as result.
However, if the valueBinding is of type Array, then the function will create an array of the correct class (in my example, class Role) and called the custom converter getAsObject function to convert every value-strings (posted from browser) into the respective value objects and return the array as result.
In the List valueBinding scenario, the returned result of List of String will eventual failed at the UISelectMany.validateValue function and throws a ValidationException.
The array valueBinding scenario on the other hand, does not have any problem at all.
It seems to be a pretty obvious bug in the reference implementation.
Is there a patch out there, a JSF RI 1.1.02 ?
Thanks
Tomas