是否有某种方法可以将 wicket 消息中的值获取到 html 属性中?
我需要获取wicket:message key="nameQtip
进入
<input type="text" id="firstName" info="Here_I_Want_The_Wicket_Message"/>
我使用 info 属性将文本传递给 qTip。
最佳答案
您可以使用 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);
}
}
如果您经常需要这个,您可以从 TextField 创建自己的子类。请注意,虽然 info 不是输入支持的属性,但 HTML validator 会提示这一点...
您还可以更静态地执行此操作:
<input wicket:id="firstName" type="text" wicket:message="info:infoMessage"/>
infoMessage 位于属性文件中。
关于java - 从 wicket 消息中设置 html 元素属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18521416/