please add to jira...

-igor


On Feb 7, 2008 2:08 AM, Sergiy Yevtushenko <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> In my app I was ought to subclass DropDownChoice just because of one small
> implementation detail of AbstractSingleSelectChoice.getModelValue():
>
> ...
>         public String getModelValue()
>         {
>                 final Object object = getModelObject();
>                 if (object != null)
>                 {
>                         int index = getChoices().indexOf(object); //<<-----
>                         return getChoiceRenderer().getIdValue(object, index);
>                 }
>                 return NO_SELECTION_VALUE;
>         }
> ...
>
> In case when getModelObject() returns, for example string (or any other kind 
> of
> key value) while list contains something different (for example POJOs with
> key-value pairs), getChoices().indexOf(object) returns -1. It happens because
> indexOf() usually implemented so it calls equals() for passed key and provides
> element list as a value, while in this case element list is more "smart" and 
> can
> match itself to passed key (of course with proper equals() method). Probably 
> it
> worth to consider replace call to indexOf() with loop and reverse the check
> (i.e. call equals() for list elements passing key as a parameter). This should
> not cause problems with existing code, but may slightly simplify life in cases
> similar to the above. Similar issue also exists in
> ListMultipleChoice.getModelValue().
>
> Regards,
>         Sergiy.
> *---------------------------------------------
> [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to