Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The ChoiceRenderer will use the value of the 'key' property of SelectOption object in the 'value' attribute in the rendered HTML (e. g. 'key' property value will be used as the option id). The 'value' property will be used as a display value for the given option. Your backing model must use SelectOption as compared to String in the simple example.

Let's rephrase that last bit paraphrasing John Krasnay's recent post to Wicket-Users...

"You give a DDC a model and a list of possible values. The type of object returned by the model and the type of objects in the list must be the same. If your model returns an Integer, so you must pass a list of Integers, not IntegerSelectChoice or anything else.

If you want to display something different than the integer, you have to implement some custom code in ChoiceRenderer.getDisplayValue(). Don't get hung up on the idea that the value returned has to be a property of
the objects in your list. It can be anything, such as the getString("period_" + object.toString()), for example."

~~~

Note

See also the JavaDoc for the ChoiceRenderer. Another example of custom ChoiceRenderer can be found in the DropDownChoice component reference in the Wicket Library.

...