Wicket:如何使用 BodyTagAttributeModifier 类? [英] Wicket: how to use the BodyTagAttributeModifier class?
问题描述
我正在尝试将 class 属性动态添加到 body 标记中,但我遇到了这个类.但我似乎无法理解如何使用这个类.我的页面类(或面板类,因为我也尝试过)中有类似的东西:
i'm trying to dynamically add the class attribute to the body tag, and i came across this class. but i can't seem to understand how to use this class. i have something like this in my page class (or panel class, as i tried with that too):
add(new BodyTagAttributeModifier("class", "homepage", this));
这甚至无法编译,说第二个参数有问题.但我认为 String 会自动被视为 wicket 中的模型,就像 Label 类一样.我在这里遗漏了什么吗?
this doesn't even compile, saying there's something wrong with the 2nd parameter. but i think String is automatically considered a Model in wicket, like the Label class. am i missing something here?
推荐答案
如果您只是将 wicket:id 添加到 body 属性并使用 AttributeAppender 类会怎样?或者,如果body属性已经有了id,就不能直接用这个类吗?
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:如何使用 BodyTagAttributeModifier 类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!