Search code examples
javawebwicketwicket-1.6

Wicket DropDownChoice renderer issue


I have a problem with displaying options in a DropDownChoice (wicket 1.6).

DropDownChoice<Boolean> choice = new DropDownChoice<Boolean>("enabled", Arrays.asList(true, false), new ChoiceRenderer<Boolean>());
choice.setNullValid(true);
choice.setOutputMarkupId(true);

enabled.nullValid=Not selected
enabled.true=Yes
enabled.false=No

nullValid is displayed properly, true and fals is not. How can I display yes and no instead of true and fals?


Solution

  • Use a custom IChoiceRenderer or override #localizeDisplayValues() to return true and define values in your resource property files (possibly prepended with the component path):

    true = yes
    false = no