I would definitely recommend leveraging the class hierarcy
of DropDownChoice/AbstractSingleSelectChoice in case you are using a single
select, and if it is multi select then respective ListMultipleChoice.

This way you can leverage the existing implementation of isSelected etc.

**
Martin

ti 30. lokak. 2018 klo 20.54 Claudia Hirt (hirt-clau...@gmx.de) kirjoitti:

> Thanks for the tip Martin Terra!
>
> And thank you for the example code Martin Grigorov! Good to know I'm on
> the right track.
>
> I still have one proplem left, I know it really is a minor thing. I
> developed a framework component for a group selectbox which takes a
> HashMap<String, T> containing the optgroups and their corresponding
> options. Working with generic option objects I use a ChoiceRenderer to
> give the user the possiblity to map the id- and display-value from the
> object. This works fine so far, until you get to
> isSelected(IModel<?> model)
> In AbstractChoice you can set an object as selected which does not have
> to be the same object as the one in the choices. It compares the objects
> id using the given choice renderer.
> But Select only does an object equals compare. And there's no way to use
> the choice renderer in isSelected correctly because there is no index in
> the method signature.
> As I said this is really a minor thing, but the inconsistency with
> AbstractChoice annoys me ;)
> How would you suggest to solve this?
>
> Best regards,
> Claudia Hirt
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to