I want to be able to create a drop-down select box based on the languages my website supports. I can't seem to find a component in Wicket that does this out-of-the-box. How can I do this?
+1
A:
I haven't tested this out, but try something like:
private Locale chosenLocale;
public LocalePage() {
Form<Void> form = new Form<Void>( "form" ) {
@Override
protected void onSubmit() {
// do something with this.chosenLocale
// perhaps getSession().setLocale(this.chosenLocale);
}
};
List<Locale> locales = new ArrayList<Locale>(Arrays.asList( Locale.ENGLISH, Locale.FRENCH ));
DropDownChoice<Locale> choice = new DropDownChoice<Locale>( "locale", new PropertyModel<Locale>( this,
"chosenLocale" ), locales, new IChoiceRenderer<Locale>() {
@Override
public Object getDisplayValue(Locale object) {
return object.toString();
}
@Override
public String getIdValue(Locale object, int index) {
return String.valueOf( index );
}
} );
add( form.add( choice.setNullValid( false ) ) );
}
with markup like:
<html>
<body>
<form wicket:id="form">
<select wicket:id="locale" />
<input type="submit" />
</form>
</body>
</html>
Brian Laframboise
2010-04-14 17:13:25
+1
A:
Have a look at this link. This is probably along the lines of what you need:
Eurig Jones
2010-04-15 08:02:25
A:
Check out wicket-library contribution: http://www.wicket-library.com/wicket-examples/forminput/
Zeratul
2010-04-19 02:08:35
A:
jobali
2010-05-10 14:49:32