Hello,
I have not found a simple way to do what I'm trying to do and I'm hoping
someone here can help. I'm sort of new to wicket...
Basically I would like to have a containing div whose class changes based on
where the class lives. So I have a HeaderPanel class and I want it to draw
differently depending on whether it's on the home page or some other page.
What I tried looks something like:
<div wicket:id="headerContainer" class="clearfix" >
<div class="headergraphic">
<div wicket:id="headerMenu" class="headermenu"></div>
.....
</div>
</div>
I want to be able to add another class to the first (headerContainer) div
depending on where the panel is drawn. I tried adding a wicket:id to this
div and then using AttributeAppender, but I got runtime errors that the div
was missing its end tag. The error looks like this (I tried both div and
span with same results):
WicketMessage: Expected close tag for <span
wicket:id="headerContainer" class="clearfix header-home">
It seems the divs (or spans) with wicket ids want to not contain other divs
before the close tag? In the code I wasn't sure how to reference the div id
- I tried WebComponent and EmptyPanel. For example:
WebComponent container = new WebComponent("headerContainer");
if (isHome) {
container.add(new AttributeAppender("class", new
Model("header-home"), " "));
}
else {
container.add(new AttributeAppender("class", new
Model("header-basic"), " "));
}
add(container);
I've read about the HeaderContributor also, but I would prefer to keep my
css in one file, since most of the inner css is the same and only a few
things change based on whether it's the header-home or header-basic class.
Is there a simple way to accomplish this? Thank you!!