On Fri, Nov 23, 2007 at 02:17:28PM +0100, Edvin Syse wrote:
> Hi,
> 
> I have a page that extends another page, and concequently the "parent" 
> page template contains the <body> element that is beeing rendered. The 
> "subpage" template contains:
> 
> <body>
>       <wicket:extend>
>               content...
>       </wicket:extend>
> </body>
> 
> In some pages I would like to add either an id or class to the body 
> element. How I can get a hold of the body to do this from the Page-class?
> 

Hi Edvin,

The <body> tag from your subpage is discarded. The <body> tag that is
rendered comes from some parent page. One way to do this would be to
attach a WebMarkupContainer to the <body> tag in the parent page and
expose it via a getter:

public class ParentPage extends WebPage {

  private WebMarkupContainer body;

  public ParentPage() {
    body = new WebMarkupContainer("body");
    // need to add all children to the body tag
    // instead of the page
  }

  protected WebMarkupContainter getBody() {
    return body;
  }
}

public class ChildPage extends ParentPage {
  public ChildPage() {
    getBody().add(new SimpleAttributeModifier("class", "foo"));
  }
}

jk

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to