myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erlend Hamnaberg <erle...@underdusken.no>
Subject Re: JSF and converters, possible bug in myfaces and RI
Date Wed, 11 Jul 2007 10:06:25 GMT
David Delbecq wrote:
> Hello,
>
> Logs from JSF -RI clearly show that converter was used to convert
> submitted string to an Alternative object. The error state that this
> converted value is not equal to any of the available SeletItem Value.
> This is obviously caused by your Alternative class not properly
> implements the equals() method. As such, it falls back to
> Object.equals() which only compare instances identifiers. And because
> the result of your converter and the result of your getAlternative()
> both return new items, equals() between them returns false.
> The reason it works if your cange model is maybe that the model used
> implement properly equals() or the backing framework you use (i don't
> know JaxB) ensure there is only 1 instance of a given Alternative with a
> give Id.
>
> So, solution
> implement the equals method.
>
> reference:
> javax.faces.component._SelectItemsUtil, method public static boolean
> matchValue(Object value, Iterator selectItemsIter)
>
> while (selectItemsIter.hasNext())
>         {
>             SelectItem item = (SelectItem) selectItemsIter.next();
>             if (item instanceof SelectItemGroup)
>             {
>                 /..../
>             }
>             else
>             {
>                 Object itemValue = item.getValue();
>                 if (value==itemValue || (itemValue.equals(value)))
>                 {
>                     return true;
>                 }
>             }
> En l'instant précis du 10/07/07 21:40, Erlend Hamnaberg s'exprimait en
> ces termes:
>   
>> Matthias Wessendorf wrote:
>>     
>>> are you sure
>>>
>>> for-class register "Alternative" is same than JaxB ?
>>>
>>> full qualified class name ?
>>>       
>> Of course fully qualified.
>> The classname in question is org.evatest.xml.Alternative.
>>
>> The behavior doesn't change weather i use this method or explicitly
>> define a converter-id.
>>     
>>> On 7/10/07, Erlend Hamnaberg <erlenha@underdusken.no> wrote:
>>>       
>>>> Hello.
>>>>
>>>> Last time i posted i didnt get much response from this questi
>>>>         
>
>
>   

Ah, obviously.

Incredible that I missed that...
Sorry for my lame questions.

-- 
Erlend Hamnaberg



Mime
View raw message