I am using markup inheritance (<wicket:child> and <wicket:extend>) and need to set the page title from my subpage. I currently add a label in the base class (BasePage.java) and make it use an abstract method getTitle(), which is overridden in the subclass
(SubPage.java). Has anybody found a better way?

Here's my solution:

<!-- BasePage.html -->
<html>
<head>
  <title wicket:id="title">[Page title]</title>
</head>
<body>
  <wicket:child/>
</body>
</html>

<!-- SubPage.html -->
<wicket:extend>
  <!-- anything ... -->
</wicket:extend>


public abstract class BasePage extends WebPage
{
  // ...
  public BasePage(final PageParameters parameters)
  {
    add(new Label("title", new PropertyModel(this, "title")));
  }
  public abstract String getTitle();
}

public class SubPage extends BasePage
{
  // ...
  public String getTitle()
  {
    return "whatever title";
  }
}

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

Reply via email to