I'd do it like this:

<h1 wicket:id="logo-h1">
<a wicket:id="logo-home">...</a>
</h1>

add(new WebMarkupContainer("logo-h1") {
    void onConfigure() {
        super.onConfigure();
setRenderBodyOnly(!getPage().getClass().equals(Homepage.class));
    }
}.add(new Link...));

In other words: only render the H1 body when not on the homepage.
setRenderBodyOnly() allows you to control if a tag should be fully rendered, or just it's body.

onConfigure() can be overriden to update a components settings whenever it is about to be rendered.

Met vriendelijke groet,
Kind regards,

Bas Gooren

schreef Scott Carpenter op 22-11-2013 19:24:
Suppose you have a web site with a logo in the header which links to the
home page. On the home page itself, you have the same logo and the link,
but you also want to wrap the logo with an H1 tag.

(Or maybe it's not that you have a burning desire to do this, but your
client has requested it.)

In my Wicket inexperiencedness, I might try this:

<wicket:enclosure child="homePageHomeLink">
   <h1><a wicket:id="homePageHomeLink" title="Home" href="#">ABC,
Inc.</a></h1>
</wicket:enclosure>
<wicket:enclosure child="homeLink">
   <a wicket:id="homeLink" title="Home" href="#">ABC, Inc.</a>
</wicket:enclosure>

And then on the Java side, set one or the other to be invisible.

That works, but I'd like to know if there's a better way.

Thank you!


Reply via email to