1 - isVisible isn't called in the constructor.
2 - A constructor is for constructing - your object should not be in
an incomplete state when the constructor is finished (such a state
that methods such as isVisible can not be called)
3 - the question was about delayed creation of child components - why
would isVisible rely on child components being created or not?  by the
time isVisible is called, any instance or model data that you need to
compute visibility should have been initialized so that the component
can work.

In my experience, typically these "needs" for delayed component
creation come not from a true need, but from a lack of understanding
of the proper use of models.

--
Jeremy Thomerson
http://www.wickettraining.com




On Fri, May 15, 2009 at 12:21 AM, Vladimir K <[email protected]> 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 <[email protected]>
>> 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
>>> <[email protected]>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: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>
>>
>>
>>
>> --
>> 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: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>>
>
> --
> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to