Set html element attribute from wicket message

拟墨画扇 提交于 2019-12-11 02:11:43

问题


Is there some way to get a value from wicket message into an html attribute?

I need to get wicket:message key="nameQtip

into

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

I'm using the info attribute to pass text to qTip.


回答1:


You can achieve this 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 this regularly, you can make own subclass from TextField. Be aware that while info is not supported attribute for input, HTML validators will complain about this...

Also you can do this more statically as:

<input wicket:id="firstName" type="text" wicket:message="info:infoMessage"/>

where infoMessage is in property file.



来源:https://stackoverflow.com/questions/18521416/set-html-element-attribute-from-wicket-message

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!