Hi, 

Clint Checketts wrote:
> 
> I don't believe the goal of onInitiallize is to move all component
> creation
> from the constructor to onInitialize, since if you are adding the
> component
> to the parent in the onInitialize method then you are back to the problem
> of
> not being able to call getPage() in your components.
> 

I think it is the opposite: if I create and add components in their
respective constructors I do not have access to getPage():


class MyPage {
  MyPage() {
    add(new MyPanel());
  }
}

class MyPanel {
  MyPanel() {
    log.debug("getPage() = " + getPage());   <= null
    add(new Label("id", getString("resKey")); <= does not resolve
  }
}


So at least in my panels and other containers I would keep creating
components in onInitialize(). Is that right?

Overridable factory methods in my base page (which should not be called from
the constructor) are mainly there to create Components, so from where can
they be called if I can't override onInitialize()? I would not like to go
back to onBeforeRender and maintain a flag myself. 

Cheers 
Hans

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/final-Page-onInitialize-tp3250951p3298712.html
Sent from the Forum for Wicket Core developers mailing list archive at 
Nabble.com.

Reply via email to