Set html element attribute from wicket
1 answer
This can be done easily with AttributeModifier
public class TextFieldInfoPage extends WebPage {
public TextFieldInfoPage() {
super();
final TextField<String> firstName = new TextField<String>("firstName");
firstName.add(new AttributeModifier("info", "Here_I_Want_The_Wicket_Message"));
add(firstName);
}
}
If you need it regularly, you can create your own subclass from TextField. Keep in mind that while the information is not supported by the input attribute, HTML validators will complain about this ...
Also you can do it more statically like:
<input wicket:id="firstName" type="text" wicket:message="info:infoMessage"/>
where infoMessage is in properties file.
+4
source to share