Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.1.0
-
None
-
None
Description
Currently the RendererUtils.findUISelectManyConverter() method assumes that, when the valueType is a List, the List must contain Strings, and therefore no Converter is needed. If the valueType is an array, then this method attempts to see if there is a Converter for the arrayComponentType (the type of objects that the array holds). A comment says that the API Doc of UISelectMany assumes that the List holds Strings, but we have an opportunity here to improve on that.
The patch I'm submitting allows the binding of a UISelectMany component to a List of objects other than Strings. The behavior ends up being the same as if we were binding to an array of some component whose type is not a String (finding a Converter in this case is already handled by the RendererUtils.findUISelectManyConverter() method.
The code that I propose adding is listed here and a patch file will be attached:
if (List.class.isAssignableFrom(valueType))
{
//According to API Doc of UISelectMany the assumed entry type for a List is String
//--> no converter needed
// However, if the List contains something other than Strings, we can attempt
// to find a suitable converter. In JDK 1.4, we can try to find out what the List
// contains by looking at the SelectItem value of the first item. With generics in
// JDK 1.5, it would be much easier to determine the type.
List selectItems = RendererUtils.internalGetSelectItemList(component);
if (selectItems != null && selectItems.size() > 0) {
SelectItem selectItem = (SelectItem) selectItems.get(0);
Class listComponentType = selectItem.getValue().getClass();
if (!(String.class.equals(listComponentType))) {
try
catch (FacesException e)
{ log.error("No Converter for type " + listComponentType.getName() + " found", e); return null; } }
}
}