Set html element attribute from wicket

Is there a way to get the value from the wicket into the html attribute?

I need to get wicket:message key="nameQtip

in

    <input type="text" id="firstName" info="Here_I_Want_The_Wicket_Message"/>

      

I am using the info attribute to pass text to qTip.

+2


source to share


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







All Articles