Hi, we just ran into an interesting problem. We are using inheritance a lot in our pages, but at one point we need something in the super page that depends on the constructor of the sub page. Just like with regular components, I thought I'd just use onInitialize() for that.
Unfortunately, that didn't work: at com....MySubPage.onInitialize(...) at org.apache.wicket.Component.fireInitialize(Component.java:4050) at org.apache.wicket.MarkupContainer.initialize(MarkupContainer.java:413) at org.apache.wicket.Page.componentAdded(Page.java:1589) at org.apache.wicket.MarkupContainer.addedComponent(MarkupContainer.java:979) at org.apache.wicket.MarkupContainer.add(MarkupContainer.java:142) at com....MySuperPage.<init>(...) See the quickstart at https://github.com/duesenklipper/wicket-oninitialize or just do this in the HomePage of any Wicket app: private final boolean constructorDone; public HomePage(final PageParameters parameters) { add(new Label("message", "blah")); this.constructorDone = true; } @Override protected void onInitialize() { super.onInitialize(); if (!constructorDone) { throw new IllegalStateException(); } } As soon as I add() the first component to the page in the super constructor, the page's initialize() is called, which fires onInitialize. At this time, my onInitialize can't do anything, since not even the super constructor has been run completely! Should this really happen this way? I.e., should the Page be initialized at this point, or should the page's onInitialize call be deferred later? Or is onInitialize not the right spot to do this for a page - what would the right way be then? Thanks Carl-Eric www.wicketbuch.de