从检票口消息设置 html 元素属性 [英] Set html element attribute from wicket message

查看:25
本文介绍了从检票口消息设置 html 元素属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以将 wicket 消息中的值转换为 html 属性吗?

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

我需要获得 wicket:message key="nameQtip

进入

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

我正在使用 info 属性将文本传递给 qTip.

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

推荐答案

您可以使用 AttributeModifier 轻松实现这一点

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);
    }

}

如果你经常需要这个,你可以从 TextField 创建自己的子类.请注意,虽然 info 不支持输入属性,但 HTML 验证器会抱怨这个...

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"/>

infoMessage 在属性文件中的位置.

where infoMessage is in property file.

这篇关于从检票口消息设置 html 元素属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆