You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Martin Marinschek (JIRA)" <my...@incubator.apache.org> on 2005/09/04 12:25:31 UTC

[jira] Closed: (MYFACES-425) findUISelectManyConverter should look for converter when valueType is List

     [ http://issues.apache.org/jira/browse/MYFACES-425?page=all ]
     
Martin Marinschek closed MYFACES-425:
-------------------------------------

    Fix Version: 1.0.10m10
     Resolution: Fixed

Applied patch, and hopefully we will not get any problems with the spec here. If yes we can always revert to the previous version.

Closing this out for now.

regards,

Martin

> findUISelectManyConverter should look for converter when valueType is List
> --------------------------------------------------------------------------
>
>          Key: MYFACES-425
>          URL: http://issues.apache.org/jira/browse/MYFACES-425
>      Project: MyFaces
>         Type: Bug
>     Versions: 1.0.10m10
>     Reporter: Ken Weiner
>     Assignee: Martin Marinschek
>      Fix For: 1.0.10m10
>  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 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
>                     {
>                         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:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira