myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Marinschek (JIRA)" <>
Subject [jira] Commented: (MYFACES-425) findUISelectManyConverter should look for converter when valueType is List
Date Thu, 01 Sep 2005 06:42:09 GMT
    [ ] 

Martin Marinschek commented on MYFACES-425:

Well, if there is nothing in the contrary mentioned in the spec, we are safe to go!



> findUISelectManyConverter should look for converter when valueType is List
> --------------------------------------------------------------------------
>          Key: MYFACES-425
>          URL:
>      Project: MyFaces
>         Type: Bug
>     Versions: Nightly Build
>     Reporter: Ken Weiner
>     Assignee: Martin Marinschek
>  Attachments: RendererUtils.patch.txt
> 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
>         	// contains by looking at the SelectItem value of the first item.  With generics
>         	// 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
>                     {
>                         return facesContext.getApplication().createConverter(listComponentType);
>                     }
>                     catch (FacesException e)
>                     {
>                         log.error("No Converter for type " + listComponentType.getName()
+ " found", e);
>                         return null;
>                     }
>                 }
>             }
>         }

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message