我是 Wicket 新手。我想知道是否有人可以帮助我解决以下问题: 我有:
.centredtab{
margin-left: auto;
margin-right: auto;
}
和:
<form class="centredtab"wicket:id="questionform">
但是表单的类centredtab
没有被渲染。 Wicket API 中是否有一种方法可以确保呈现此类属性以使表单居中?
谢谢!
最佳答案
Wicket 简单属性附加器可拯救您,请参阅此处 http://wicket.apache.org/apidocs/1.4/org/apache/wicket/behavior/AttributeAppender.html
本质上,
myForm.add(new AttributeAppender("class",
new Model<String>("centredtab"), " "));
<小时/>
好吧。我认为您缺少参数 addAttributeIfNotPresent
(请参阅上面的文档)
试试这个
myForm.add(new AttributeAppender("class", true,
new Model<String>("centredtab"), " "));
如引用
AttributeAppender(String attribute, boolean addAttributeIfNotPresent, IModel<?> appendModel, String separator)
Creates an AttributeModifier that appends the appendModel's value to the current value of the attribute, and will add the attribute when addAttributeIfNotPresent is true.
应该可以解决您不创建属性的问题。
希望这有帮助。
关于java - 当组件有 wicket :id? 时如何输出类标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4891639/