ok, so i did research again for a while, and i think i got the result i want
by using the aother method described here:
http://www.nabble.com/Dynamically-Change-css-style-of-body-tag-td13505908.html#a13505908

so basically here is the code to get add a class attribute to the body tag:

        <body wicket:id="body"> <!-- not wicket:id="foo" like in the link
-->

        add(new WebMarkupContainer("body"){
            @Override
            public boolean isTransparentResolver() {
                return true;
            }
            @Override
            protected void onComponentTag(ComponentTag tag) {
                tag.put("class",  "somestyle");
            }
        });

i would appreciate if someone can explain to me why the above code actually
works and the BodyTagAttributeModifier didn't. btw, i now knew that String
is not automatically cast to Model. my bad.
anyways, what's wrong with this:

        add(new BodyTagAttributeModifier("class", true, new
Model<String>("somestyle"), this));

it looks much cleaner than using the WebMarkupContainer. i would really like
to get it working.


jianfei wrote:
> 
> 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));
> 
> 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? i tried to search up on
> this topic, but there is no concrete example on how to use this class. i'm
> using wicket 1.4
> 
> 

-- 
View this message in context: 
http://www.nabble.com/how-to-use-the-BodyTagAttributeModifier-class--tp24875297p24875789.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to