I'm a Wicket newbie. I wonder if someone could help me with the following:
I have:
.centredtab{
margin-left: auto;
margin-right: auto;
}
and:
<form class="centredtab"wicket:id="questionform">
but the class centredtab
for the form is not being rendered. Is there a method in the Wicket API to ensure that this class attribute will be rendered in order that the form is centred?
Thanks!
Wicket simple attribute appender to rescue you see here http://wicket.apache.org/apidocs/1.4/org/apache/wicket/behavior/AttributeAppender.html
Essentially,
myForm.add(new AttributeAppender("class",
new Model<String>("centredtab"), " "));
alright. I think you're missing the parameter addAttributeIfNotPresent
(refer the doc above)
Try this
myForm.add(new AttributeAppender("class", true,
new Model<String>("centredtab"), " "));
As quoted
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.
should solve your issue of not creating the attribute.
Hope this helps.