Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add another solution based on Wicket models.

...

. There are however a number of typical solutions.

Use Model

Code Block

public abstract class Template extends WebPage {

  public Template(PageParameters params) {
     super(params);
     add(new Label("headerTitle", getPageTitle()));
  }
  protected abstract IModel<String> getPageTitle();
}

This way the model implementation will be constructed at component construction time but its #getObject() will be called at component rendering time and the object we need will be already properly constructed.

Two-phase construction with an internal init() method called by subclasses

...