A simple solution is to create a custom model which stores the result of
Locale.getAvailableLocales() in a list, and you sort that list with a
custom comparator.
You can then pass this model to your DropDownChoice and have the result
you were looking for.
Bas
Op 21-4-2011 16:46, schreef xFlasH:
Hi all,
I've used quite intensively the DropDownChoice component on my forms.
But in some cases, I've added to some of those DropDownChoices some
ChoiceRenderer.
The choices Model I could pass to CTOR could easily be sorted, but in this
case, not the rendered values behind this list .
As an example this code :
DropDownChoice<Locale> locs = new DropDownChoice<Locale>("locs"
, new PropertyModel<Locale>(this, "session.locale")
, Arrays.asList(Locale.getAvailableLocales())
, new IChoiceRenderer<Locale>() {
public Object getDisplayValue(Locale object) {
return object.getDisplayName();
}
public String getIdValue(Locale object, int index) {
return Integer.toString(index);
}
}
);
This code would build a select element but the rendered values (based on
your current Locale) would not be sorted.
If I sort the Locale.getAvailableLocales() list, this will result in an
indexed based sorted list, not on a ChoiceRendered base.
How could I sort this kind of dropdownChoices ? What would be the best
solution ?
Thanks a lot for your answer.
-R-
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-sorted-choice-rendered-Values-tp3466087p3466087.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org