by your own argument your own code will have to call your second-chance init constructor before invoking *any* method on the component.
so instead of boolean visible=getMyComponent().isvisible(); you will have to now do Component c=getMyComponent(); if (!c.isinitted()) {c.initI(); } boolean visible=c.isvisible(); that init line is now necessary because you *never* know if a component has been initialized, so every access to any component memeber has to be prefixed by that init check. that will be fun! or we can just use constructors since thats what they are designed to do (its in the name) -igor On Thu, May 14, 2009 at 10:21 PM, Vladimir K <koval...@gmail.com> wrote: > > it has just come to my mind .... > > I'm afraid Wicket can't guarantee that onBeforeRender would be called in any > case. So there could be a case (isVisible() for instance) when > onBeforeRender is not called yet but overriding method could read > yet-not-completely-initialized object state. > > Instead of thinking how to work around isVisible() and the other cases why > not just add a second-chance method and invoke it in appropriate places. > > in Component: > > boolean complete = false; > void ensureCompletelyInitialized() { > if(!complete){ > finalizeCreation(); > complete = true; > } > } > > void internalBeforeRender() { > ensureCompletelyInitialized(); > ... > } > > I believe it makes sence. > > > Martijn Dashorst wrote: >> >> This has been discussed till death previously and we have excluded it >> from our roadmap. We will never have an init() method for components. >> Gossling gave us a Constructor to initialize your Objects. >> >> Search and read the archives if you want more information on the subject. >> >> Martijn >> >> On Fri, May 15, 2009 at 12:36 AM, Juan G. Arias <juangar...@gmail.com> >> wrote: >>> It would be very nice to add a new phase for component creation, like I >>> said, an init() or createContent(). >>> Is there a JIRA issue for that? >>> If yes, I will vote for it and suggest to change the name to something >>> _not_ >>> related to the rendre phase. >>> >>> Thanks! >>> Juan >>> >>> >>> On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch >>> <daniel.st...@gmail.com>wrote: >>> >>>> I think you can use hasBeenRendered() method instead of custom boolean >>>> flag. >>>> >>>> -- >>>> Daniel >>>> >>>> On 2009-05-14, at 20:15, Jeremy Thomerson wrote: >>>> >>>> You could probably do it in onBeforeRender - but you would need to >>>>> keep a boolean flag to check if it's the first render so that you >>>>> don't recreate them on a second render.... There was talking of >>>>> adding an onBeforeFirstRender method, but I don't think it's happened >>>>> yet - you could look for the method to see if I'm wrong. >>>>> >>>>> -- >>>>> Jeremy Thomerson >>>>> http://www.wickettraining.com >>>>> >>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>>> For additional commands, e-mail: users-h...@wicket.apache.org >>>> >>>> >>> >> >> >> >> -- >> Become a Wicket expert, learn from the best: http://wicketinaction.com >> Apache Wicket 1.3.5 is released >> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> >> > > -- > View this message in context: > http://www.nabble.com/Component-creation-and-initialization-tp23545666p23553618.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org