Another reason is that the components hierarchy isn't built yet in the 
constructor.

Indeed, when writing add(new MyComponent("id"));, the component is first 
constructed and then added.

As such, using methods like getPage() or getForm() in the constructor results 
in exceptions being thrown at runtime.

++
  _____  

From: mbrictson [mailto:[email protected]]
To: [email protected]
Sent: Sat, 03 Apr 2010 01:49:49 +0200
Subject: Re: What about an onInitialRender method ?


  Good example. Thanks for clarifying.
  
  
  igor.vaynberg wrote:
  > 
  > one usecase is when you want the user to be able to change which
  > components will be created.
  > 
  > this is bad:
  > 
  > class mycomponent extends panel {
  >   public mycomponent(string id) { add(newCounter("counter")); }
  >   protected Component newCounter(String id) { return new Label(id, ....);
  > }
  > }
  > 
  > because you are calling an overridable method from constructor
  > 
  
  -- 
  View this message in context: 
http://old.nabble.com/What-about-an-onInitialRender-method---tp28122954p28123955.html
  Sent from the Wicket - User mailing list archive at Nabble.com.
  
  
  ---------------------------------------------------------------------
  To unsubscribe, e-mail: [email protected]
  For additional commands, e-mail: [email protected]
  
    

Reply via email to