You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Vitaly Tsaplin <vi...@gmail.com> on 2008/02/26 12:04:15 UTC

DropDownChoice puzzle

   Hi everyone!

   I have a question regarding the IChoiceRenderer interface. As I can
guess a regular usage of the DropDownChoice is to bind it to some bean
property (somehow probably by means of the PropertyModel). So lets
take an example. I have a picker of something that is an integer by
nature by has a human readable label. I have several options. I can
provide a choice renderer which will look up in a map (in a generic
case) to find a proper text for the item being rendered. But it's not
an efficient. Next option is to create a key-value pair to handle
both. It's efficient because the list of choices can be precreated.
But my bean has an integer property and even in case if I provide a
specific converter for that pair in one direction (probably a proxy
model) I cannot provide a setter just because the DropDownChoice will
do a lookup in its choices for a pair to retrieve using a given
integer as a parameter (it calls indexOf). I can provide my own
implementation of   equals method but indexOf will try to call equals
on a provided integer (not on a pair). I can wrap an integer parameter
and this way reverse a comparison... but finally once the
DropDownChoice will find a proper choice in its list it will take an
index and call a renderer with this index and my integer wrapper!! :)
The third option is to use an option index to link both the value and
its textual representation. I like this solution BUT the
IChoiceRenderer in its getDisplayValue method does not accept an index
(getIdValue  does). Amassing puzzle! :)
   Any ideas?

   Best regards,
   Vitaly

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org