我正在尝试将 class 属性动态添加到 body 标记中,我遇到了这个类。但我似乎无法理解如何使用这个类。我的页面类(或面板类,我也尝试过)中有类似的东西:
add(new BodyTagAttributeModifier("class", "homepage", this));
这甚至没有编译,说第二个参数有问题。但我认为 String 会自动被视为检票口中的模型,例如 Label 类。我在这里错过了什么吗?
我正在尝试将 class 属性动态添加到 body 标记中,我遇到了这个类。但我似乎无法理解如何使用这个类。我的页面类(或面板类,我也尝试过)中有类似的东西:
add(new BodyTagAttributeModifier("class", "homepage", this));
这甚至没有编译,说第二个参数有问题。但我认为 String 会自动被视为检票口中的模型,例如 Label 类。我在这里错过了什么吗?
What if you just add an wicket:id to the body attribute and use the AttributeAppender class? Or, if the body attribute already has an id, can't you just use this class?
http://wicket.sourceforge.net/apidocs/wicket/behavior/AttributeAppender.html
一些 Wicket 组件具有此字符串到模型的快捷方式(如标签),但这不是一般功能。您必须手动将您的字符串转换为模型:
add(new BodyTagAttributeModifier("class", Model.of("homepage"), this));