[ 
https://issues.apache.org/jira/browse/TOMAHAWK-1403?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Leonardo Uribe resolved TOMAHAWK-1403.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.1.10-SNAPSHOT
         Assignee: Leonardo Uribe

I checked again this one, comparing it with the new behavior of f:selectItems 
on JSF 2.0, and it seems the "wrong" documentation was inherited from 
f:selectItems. Anyway, the component does not preserve the behavior of the 
parent component.

To solve this one, we put a condition on getValue: if getVar returns null use 
the same behavior as the parent, otherwise use the algorithm inside this 
component. Also, it was added a property called useEntryAsItem, to allow the 
suggested syntax:

<t:selectItems value="#{myBean.allRoles}" var="mapEntry" useEntryAsItem="true"
itemLabel="#{mapEntry.key}" itemValue="#{mapEntry.value}" />


> t:selectItems behaviour with Map values is weird
> ------------------------------------------------
>
>                 Key: TOMAHAWK-1403
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1403
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>    Affects Versions: 1.1.8
>            Reporter: Simon Kitching
>            Assignee: Leonardo Uribe
>             Fix For: 1.1.10-SNAPSHOT
>
>
> The t:selectItems tag documentation says that the value attribute can return 
> a Map, and that a list of select-items is built using the key and value of 
> the map. The docs are completely wrong. 
> This was originally reported by Johannes Ruthenberg here:
>   
> http://mail-archives.apache.org/mod_mbox/myfaces-users/200903.mbox/%[email protected]%3e
> The situation appears to be that:
> (a) the myfaces f:selectItems tag handles situations where the value is a Map 
> by building a list of SelectItems from the map value/key automatically. This 
> may not be compliant with the JSF specification; I don't know of anywhere 
> that this behaviour is specified. The class that does this is 
> SelectItemsIterator (from myfaces shared library).
> (b) The tomahawk t:selectItems tag maps to the AbstractUISelectItems 
> component class. This overrides the handling of Map objects by building the 
> SelectItem list itself, which disables the behaviour from (a) as the 
> SelectItemsIterator never sees the Map object. The AbstractUISelectItems 
> custom Map handling does NOT use the map keys when building the SelectItem 
> list, ie its behaviour is quite different from what SelectItemsIterator does 
> for maps. It does make it possible to do some other things when building the 
> SelectItems list, but using the map key is impossible.
> It would be nice to know whether behaviour (a) is also implemented in 
> Mojarra. If that behaviour is also in Mojarra, then it would be nice for 
> t:selectItems to be able to behave in a compatible manner. At the least, the 
> t:selectItems documentation needs to be updated in 
> tomahawk/core/src/main/tagdoc/t_selectItems-base.xml
> The custom Map handling in AbstractUISelectItems was originally added by 
> Cagatay. It is not clear where the wrong documentation came from, but that is 
> more recent.
> See the email thread for more details.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to