You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Juan G. Arias" <ju...@gmail.com> on 2009/05/14 19:51:10 UTC

Component creation and initialization

Hi all,
Is there a way in wicket for separate the object's instantiation phase from
the inner component's creation phase?
Just like the "init()" method in application, but for my components.

Another way to see it, just in case it's not clear:
Is there an already defined contract for component creation, that allows me
to create the components I will use in some panel/page, but not to do it in
the Java constructor?

Thanks in advance!
Juan

Re: Component creation and initialization

Posted by Vladimir K <ko...@gmail.com>.
Igor,
I didn't mean spreading this approach everywhere :) My intention was to draw
your attention on that onBeforeRender probably is a good place to delay
construction but should be used with extra care and some sort of
simplification (more appropriate method) would be great.

You turned it insideout and it does not make sence anymore :)

Igor, Jeremy, thanks a lot for your suggestions. I have some food for my
brain to think about.


igor.vaynberg wrote:
> 
> 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 <ko...@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 <ju...@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
>>>> <da...@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-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23554417.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Igor Vaynberg <ig...@gmail.com>.
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 <ko...@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 <ju...@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
>>> <da...@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-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by James Carman <jc...@carmanconsulting.com>.
On Sun, May 17, 2009 at 6:17 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> IOC works fine if you use constructor injection :) which is what you
> should use. the only reason people may prefer setter injection is that
> configuration looks nicer.

And, when circular dependencies won't allow you to use
constructor-based injection (only an issue with "class-based"
proxies).

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Martin Grigorov <mc...@e-card.bg>.
El dom, 17-05-2009 a las 15:17 -0700, Igor Vaynberg escribió:
> IOC works fine if you use constructor injection :) which is what you
> should use. 
+1

Tor Iver, take a look at http://misko.hevery.com/code-reviewers-guide/
It is a very good reading! 

> the only reason people may prefer setter injection is that
> configuration looks nicer.
> 
> <param name="service" ref="some.service"/>
> 
> looks a lot nicer then
> 
> <constructor-arg index="2" ref="some.service"/>
> 
> -igor
> 
> On Sun, May 17, 2009 at 2:50 PM, Wilhelmsen Tor Iver <To...@arrive.no> wrote:
> >> 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)
> >
> > Tha language ensures that the object is "complete" when the constructor
> > exits, but with the exception of immutalbe objects, as a "component" it
> > is not complete. People are e.g. adding to lists at runtime, leading to
> > possible "subcomponent initialiation" later on in the relevant method of
> > a Loop or ListView for instance. It could also be argued for instance
> > that a LoadableDetachableModel is /intentionally/ "incomplete" when the
> > constructor exits. Overriding methods like isVisible() is also a form of
> > "hack" to postpone a property value to a later time (basically the
> > component stops having a "real" property called visible since the setter
> > modifies a variable that the getter does not care about).
> >
> > The desire to have "completeness" after constructor completion also runs
> > afoul with modern ideas like IoC where it is left to an outside agent to
> > complete configuration of a component.
> >
> > However, I agree that the attention of the thread originator should be
> > on the models.
> >
> > - Tor Iver
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Igor Vaynberg <ig...@gmail.com>.
IOC works fine if you use constructor injection :) which is what you
should use. the only reason people may prefer setter injection is that
configuration looks nicer.

<param name="service" ref="some.service"/>

looks a lot nicer then

<constructor-arg index="2" ref="some.service"/>

-igor

On Sun, May 17, 2009 at 2:50 PM, Wilhelmsen Tor Iver <To...@arrive.no> wrote:
>> 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)
>
> Tha language ensures that the object is "complete" when the constructor
> exits, but with the exception of immutalbe objects, as a "component" it
> is not complete. People are e.g. adding to lists at runtime, leading to
> possible "subcomponent initialiation" later on in the relevant method of
> a Loop or ListView for instance. It could also be argued for instance
> that a LoadableDetachableModel is /intentionally/ "incomplete" when the
> constructor exits. Overriding methods like isVisible() is also a form of
> "hack" to postpone a property value to a later time (basically the
> component stops having a "real" property called visible since the setter
> modifies a variable that the getter does not care about).
>
> The desire to have "completeness" after constructor completion also runs
> afoul with modern ideas like IoC where it is left to an outside agent to
> complete configuration of a component.
>
> However, I agree that the attention of the thread originator should be
> on the models.
>
> - Tor Iver
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: SV: Component creation and initialization

Posted by Vladimir K <ko...@gmail.com>.
>From my perspective the isVisible() case deserves generification. I know that
there is a task for Wicket 1.5. I mean after that we should write an article
in Wiki.


Wilhelmsen Tor Iver wrote:
> 
> Overriding methods like isVisible() is also a form of
> "hack" to postpone a property value to a later time (basically the
> component stops having a "real" property called visible since the setter
> modifies a variable that the getter does not care about).
> 

-- 
View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23592389.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


SV: Component creation and initialization

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> 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)

Tha language ensures that the object is "complete" when the constructor
exits, but with the exception of immutalbe objects, as a "component" it
is not complete. People are e.g. adding to lists at runtime, leading to
possible "subcomponent initialiation" later on in the relevant method of
a Loop or ListView for instance. It could also be argued for instance
that a LoadableDetachableModel is /intentionally/ "incomplete" when the
constructor exits. Overriding methods like isVisible() is also a form of
"hack" to postpone a property value to a later time (basically the
component stops having a "real" property called visible since the setter
modifies a variable that the getter does not care about).

The desire to have "completeness" after constructor completion also runs
afoul with modern ideas like IoC where it is left to an outside agent to
complete configuration of a component.

However, I agree that the attention of the thread originator should be
on the models.

- Tor Iver

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Jeremy Thomerson <je...@wickettraining.com>.
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 <ko...@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 <ju...@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
>>> <da...@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-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Vladimir K <ko...@gmail.com>.
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 <ju...@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
>> <da...@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-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Vladimir K <ko...@gmail.com>.
The horse is pretty alive -
https://issues.apache.org/jira/browse/WICKET-1134. 


Jeremy Thomerson-5 wrote:
> 
> With regards to multiple wicket:extend tags - that is also an old,
> dead horse that doesn't need to be beat right now.  The user list has
> a lot of discussion on it.  The simplest way to allow a child to
> contribute multiple components to a page is the same as you would do
> in normal java (which does not allow multiple inheritance) - expose
> multiple overridable methods that provide the components... i.e.:
> 

-- 
View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23557008.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Vladimir K <ko...@gmail.com>.
I'm doing just right like you described. Probably I have to pay more
attention to your comment about improper use of models. isVisible method
should rely only on the component model. I some cases it is easier to
delegate some calls to aggregated components. But instead I have to work
with component own model itself.


Jeremy Thomerson-5 wrote:
> 
> expose multiple overridable methods that provide the components... i.e.:
> 
> // I don't have my IDE open, so some method names may be wrong
> ParentComponent  {
> 
>   public void onBeforeRender {
>     if (!hasBeenRendered()) {
>       add(createLeftNavPanel(getModel()));
>       add(createContentPanel(getModel()));
>       add(createTopHeaderPanel(getModel()));
>     }
> 
>     protected Component createContentPanel(IModel model) {
>       // this can be overridden in subclasses
>       return MyDefaultTypeOfContentPanel(model);
>     }
> }
> 
> --
> Jeremy Thomerson
> http://www.wickettraining.com
> 
> 
> 
> 
> On Fri, May 15, 2009 at 12:54 AM, Vladimir K <ko...@gmail.com> wrote:
>>
>> Jeremy,
>>
>> I can't add another example to mentioned RepeatingView.
>> Concerning RepeatingView... Wicket allow me just one point to subclass
>> parent component markup within <wicket:child/> tag. RepeatingView comes
>> in
>> handy. It allows me to reserve some places in base component markup and
>> put
>> something there in subclasssing component markup. I saw examples of that
>> in
>> some projects when studying Wicket. So I just copy the idea without
>> thinking
>> about WHEN to call the overridden method that fills in the RepeatingView
>> instance. It is my fault :)
>>
>> If you add "name" attribute to wicket:child tag, and multiple
>> <wicket:extend
>> name="..."> tags I would use it instead of RepeatingView.
>>
>> Concerning your post on onBeforeRender ... I didn't say that it is
>> related
>> to class' constructor. Yes it is related to delayed component creation.
>> And
>> the reason why I delay creation is to follow mentioned rule. It is not
>> related to use of models in my case. I delay creation to allow
>> subclassing
>> components to replace some default parts of base component. Probably I'm
>> doing something wrong. Then suggest me how to do it right. For instance I
>> would like to subclass NatigationToolbar in DefaultDataTable. What should
>> I
>> do?
>>
>>
>> Jeremy Thomerson-5 wrote:
>>>
>>> Do you have any examples of where Wicket calls an overridable method
>>> from the constructor of a Wicket class?  If so, please file it as a
>>> JIRA - that would be a bug.
>>>
>>> Most java programmers know not to call overridable methods from the
>>> constructor as a general rule, although there are times when it could
>>> inadvertantly happen - which is why we need bug reports if you see
>>> that happening.
>>>
>>> --
>>> Jeremy Thomerson
>>> http://www.wickettraining.com
>>>
>>>
>>>
>>>
>>> On Fri, May 15, 2009 at 12:01 AM, Vladimir K <ko...@gmail.com> wrote:
>>>>
>>>> Martijn,
>>>>
>>>> here Java is not safe as a language. Yo're able to invoke overrided
>>>> methods
>>>> on non-completely constructed objects.
>>>>
>>>> from my perspective it is a regular case in Wicket:
>>>>
>>>> class SampleComponent extends ... {
>>>>    String parameter;
>>>>
>>>>    SampleComponent(String id, String parameter) {
>>>>        super(id);
>>>>        this.parameter = parameter;
>>>>    }
>>>>
>>>>    // method is called from within superconstructor
>>>>    @Override
>>>>    void createAdditionalComponents(RepeatingView rv) {
>>>>        useSomehow(parameter);
>>>>    }
>>>> }
>>>>
>>>> I know two approaches to work around:
>>>> - onBeforeRender
>>>> - a closure as a constructor formal parameter.
>>>>
>>>> But the latter does not help with built-in components.
>>>>
>>>> If Wicket does not help us with adding appropriate method for
>>>> second-step-initialization it should document it in wiki, javadoc and
>>>> books
>>>> "dear user, when overriding methods, beware using of yet unassigned
>>>> constructor parameters". Hmm ... sounds stupid :)
>>>>
>>>>
>>>> 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 <ju...@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
>>>>>> <da...@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-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.html
>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Component-creation-and-initialization-tp23545666p23553847.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23554210.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Jeremy Thomerson <je...@wickettraining.com>.
For your example (NavigationToolbar in DefaultDataTable) - just don't
use DefaultDataTable.  DDT is provided simply as a convenience with
the most common features of a table.  If it does not suit your needs,
create your own subclass of DataTable that uses whatever features you
want.  You will see that it can be done with a few lines of code.

With regards to multiple wicket:extend tags - that is also an old,
dead horse that doesn't need to be beat right now.  The user list has
a lot of discussion on it.  The simplest way to allow a child to
contribute multiple components to a page is the same as you would do
in normal java (which does not allow multiple inheritance) - expose
multiple overridable methods that provide the components... i.e.:

// I don't have my IDE open, so some method names may be wrong
ParentComponent  {

  public void onBeforeRender {
    if (!hasBeenRendered()) {
      add(createLeftNavPanel(getModel()));
      add(createContentPanel(getModel()));
      add(createTopHeaderPanel(getModel()));
    }

    protected Component createContentPanel(IModel model) {
      // this can be overridden in subclasses
      return MyDefaultTypeOfContentPanel(model);
    }
}

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




On Fri, May 15, 2009 at 12:54 AM, Vladimir K <ko...@gmail.com> wrote:
>
> Jeremy,
>
> I can't add another example to mentioned RepeatingView.
> Concerning RepeatingView... Wicket allow me just one point to subclass
> parent component markup within <wicket:child/> tag. RepeatingView comes in
> handy. It allows me to reserve some places in base component markup and put
> something there in subclasssing component markup. I saw examples of that in
> some projects when studying Wicket. So I just copy the idea without thinking
> about WHEN to call the overridden method that fills in the RepeatingView
> instance. It is my fault :)
>
> If you add "name" attribute to wicket:child tag, and multiple <wicket:extend
> name="..."> tags I would use it instead of RepeatingView.
>
> Concerning your post on onBeforeRender ... I didn't say that it is related
> to class' constructor. Yes it is related to delayed component creation. And
> the reason why I delay creation is to follow mentioned rule. It is not
> related to use of models in my case. I delay creation to allow subclassing
> components to replace some default parts of base component. Probably I'm
> doing something wrong. Then suggest me how to do it right. For instance I
> would like to subclass NatigationToolbar in DefaultDataTable. What should I
> do?
>
>
> Jeremy Thomerson-5 wrote:
>>
>> Do you have any examples of where Wicket calls an overridable method
>> from the constructor of a Wicket class?  If so, please file it as a
>> JIRA - that would be a bug.
>>
>> Most java programmers know not to call overridable methods from the
>> constructor as a general rule, although there are times when it could
>> inadvertantly happen - which is why we need bug reports if you see
>> that happening.
>>
>> --
>> Jeremy Thomerson
>> http://www.wickettraining.com
>>
>>
>>
>>
>> On Fri, May 15, 2009 at 12:01 AM, Vladimir K <ko...@gmail.com> wrote:
>>>
>>> Martijn,
>>>
>>> here Java is not safe as a language. Yo're able to invoke overrided
>>> methods
>>> on non-completely constructed objects.
>>>
>>> from my perspective it is a regular case in Wicket:
>>>
>>> class SampleComponent extends ... {
>>>    String parameter;
>>>
>>>    SampleComponent(String id, String parameter) {
>>>        super(id);
>>>        this.parameter = parameter;
>>>    }
>>>
>>>    // method is called from within superconstructor
>>>    @Override
>>>    void createAdditionalComponents(RepeatingView rv) {
>>>        useSomehow(parameter);
>>>    }
>>> }
>>>
>>> I know two approaches to work around:
>>> - onBeforeRender
>>> - a closure as a constructor formal parameter.
>>>
>>> But the latter does not help with built-in components.
>>>
>>> If Wicket does not help us with adding appropriate method for
>>> second-step-initialization it should document it in wiki, javadoc and
>>> books
>>> "dear user, when overriding methods, beware using of yet unassigned
>>> constructor parameters". Hmm ... sounds stupid :)
>>>
>>>
>>> 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 <ju...@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
>>>>> <da...@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-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23553847.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Vladimir K <ko...@gmail.com>.
Jeremy,

I can't add another example to mentioned RepeatingView.
Concerning RepeatingView... Wicket allow me just one point to subclass
parent component markup within <wicket:child/> tag. RepeatingView comes in
handy. It allows me to reserve some places in base component markup and put
something there in subclasssing component markup. I saw examples of that in
some projects when studying Wicket. So I just copy the idea without thinking
about WHEN to call the overridden method that fills in the RepeatingView
instance. It is my fault :)

If you add "name" attribute to wicket:child tag, and multiple <wicket:extend
name="..."> tags I would use it instead of RepeatingView.

Concerning your post on onBeforeRender ... I didn't say that it is related
to class' constructor. Yes it is related to delayed component creation. And
the reason why I delay creation is to follow mentioned rule. It is not
related to use of models in my case. I delay creation to allow subclassing
components to replace some default parts of base component. Probably I'm
doing something wrong. Then suggest me how to do it right. For instance I
would like to subclass NatigationToolbar in DefaultDataTable. What should I
do?


Jeremy Thomerson-5 wrote:
> 
> Do you have any examples of where Wicket calls an overridable method
> from the constructor of a Wicket class?  If so, please file it as a
> JIRA - that would be a bug.
> 
> Most java programmers know not to call overridable methods from the
> constructor as a general rule, although there are times when it could
> inadvertantly happen - which is why we need bug reports if you see
> that happening.
> 
> --
> Jeremy Thomerson
> http://www.wickettraining.com
> 
> 
> 
> 
> On Fri, May 15, 2009 at 12:01 AM, Vladimir K <ko...@gmail.com> wrote:
>>
>> Martijn,
>>
>> here Java is not safe as a language. Yo're able to invoke overrided
>> methods
>> on non-completely constructed objects.
>>
>> from my perspective it is a regular case in Wicket:
>>
>> class SampleComponent extends ... {
>>    String parameter;
>>
>>    SampleComponent(String id, String parameter) {
>>        super(id);
>>        this.parameter = parameter;
>>    }
>>
>>    // method is called from within superconstructor
>>    @Override
>>    void createAdditionalComponents(RepeatingView rv) {
>>        useSomehow(parameter);
>>    }
>> }
>>
>> I know two approaches to work around:
>> - onBeforeRender
>> - a closure as a constructor formal parameter.
>>
>> But the latter does not help with built-in components.
>>
>> If Wicket does not help us with adding appropriate method for
>> second-step-initialization it should document it in wiki, javadoc and
>> books
>> "dear user, when overriding methods, beware using of yet unassigned
>> constructor parameters". Hmm ... sounds stupid :)
>>
>>
>> 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 <ju...@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
>>>> <da...@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-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23553847.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Vladimir K <ko...@gmail.com>.
If the question is ressurecting again and again then it is an evidence that
there is something to address and improve. At least Wicket does not have a
method with self-documented name which deffers component creation. As the
result people have to search (using different words) and they don't satisfy
with the result 'cause the topic is still looks open.

This list is quite active and I appreciate the answers of core developers.
Probably Wicket is so good because in addition to the devotion of talented
and capable people to implementation, they do hear what the users say
directly, not indirectly via support team.


Jeremy Thomerson-5 wrote:
> 
> I actually had to Google that one.  But, yes, that is the general
> consensus that I've seen.  If you wanted to write a page that showed
> the different ways that you mentioned, that would be fine.  It really
> just depends on if you really need lazy component creation, and then
> how you want to implement it.
> 
> --
> Jeremy Thomerson
> http://www.wickettraining.com
> 
> 
> 
> 
> On Fri, May 15, 2009 at 11:13 AM, Clint Popetz <cl...@42lines.net> wrote:
>> TMTOWTDI
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23582495.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Jeremy Thomerson <je...@wickettraining.com>.
I actually had to Google that one.  But, yes, that is the general
consensus that I've seen.  If you wanted to write a page that showed
the different ways that you mentioned, that would be fine.  It really
just depends on if you really need lazy component creation, and then
how you want to implement it.

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




On Fri, May 15, 2009 at 11:13 AM, Clint Popetz <cl...@42lines.net> wrote:
> TMTOWTDI

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Clint Popetz <cl...@42lines.net>.
On Fri, May 15, 2009 at 10:24 AM, Jeremy Thomerson
<je...@wickettraining.com> wrote:
> Interestingly, in the long-standing defacto
> article on asking smart questions, the very first thing it says to do
> is to search the forums [1].

FWIW, I did search the list, before posting.  I found a lot of
disagreement about this topic, no resolution, and mostly threads that
just trailed off.   I was hoping that perhaps there was a consensus
pointing to a best practice with respect to creating component
hierarchies in wicket that works around the problem of constructors in
java, but that does not seem to be the case.  Some people advocate
onBeforeRender with checks to make sure it's the first time, some
people advocated adding an onBeforeFirstRender() to the framework,
which never made it in.  Some use init() methods like I posted, and
some use factory patterns.  If the consensus is just that TMTOWTDI,
that's fine too I suppose, but it will result in this thread
resurfacing bi-monthly.

If I were to write up a wiki document right now on this topic, it
would reflect my own confusion on this topic, so I'll wait until
lucidity arrives.

-Clint

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Documentation is always welcome.  This is a very active list (one of
the most active that I've seen with an open source project) where the
core devs spend a lot of quality time answering questions.  There's
not enough hours in the day for us to also add that to documentation
or provide everyone with links to documentation when so much of it is
available by using smart searches on the plethora of available list
searching sites.  I use Nabble extensively.  So, you will hear "search
the list" quite a bit.  Interestingly, in the long-standing defacto
article on asking smart questions, the very first thing it says to do
is to search the forums [1].

So, the long and short of it is that we need folks like yourself who
may not spend as much time answering questions on the list but will
take the initiative to pull out the useful tidbits and document them
on the wiki, organize the wiki so that it's easier to navigate, etc.
Many times that is thankless work, but it is appreciated nonetheless.
THANK YOU!

[1] - http://catb.org/esr/faqs/smart-questions.html#before

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




On Fri, May 15, 2009 at 7:59 AM, Clint Popetz <cl...@42lines.net> wrote:
> On Fri, May 15, 2009 at 12:07 AM, Jeremy Thomerson
> <je...@wickettraining.com> wrote:
>>
>> Most java programmers know not to call overridable methods from the
>> constructor as a general rule, although there are times when it could
>> inadvertantly happen - which is why we need bug reports if you see
>> that happening.
>>
>
> I've only been on the wicket  list for a few months, and I can
> understand the annoyance of bringing up a subject that's perhaps been
> beaten to death, but to me that means the resulting consensus to be
> documented in the wiki, rather than pointing users to "search the
> list."  So whatever comes out of this thread, I'll add it to the wiki
> (unless it's already there, in which case I apologise.)
>
> This isn't just a matter of whether Wicket internally calls
> overridable methods.
>
> What ends up happening (only in my experience) is that inheritance for
> pages ends up needing you to create your own internal init() mechanism
> in order to ensure that subclasses are ready to effectively override
> methods for base class component creation.  I'm not suggesting that
> Wicket provide this type of init() mechanism, but in my experience it
> is a pattern that crops up, and it should be documented as such.  If
> it is already documented, my apologies.  If it's an anti-pattern,
> what's the alternative?
>
>
> public class Template extends WebPage {
>  public Template(PageParameters params) {
>    setupParams(params);
>    add(new Label("title",getTitle()));
>  }
>
>  pubilc void setupParams(PageParameters params) { }
>  public String getTitle() { return "Title should be overriden"; }
> }
>
> public class SpecificPage extends Template {
>  Object somethingCreatedBasedOnParams;
>  public SpecificPage(PageParameters params) {
>    super(params);
>  }
>  public void setupParams(PageParameters params) {
>      //set up somethingCreatedBasedOnParams
>  }
>  public String getTitle() {
>    return "A page about " + somethingCreatedBasedOnParams.getFoo();
>  }
> }
>
> This same pattern evolves in my experience even if you are using
> panels for templating, because you need the base class to add() the
> panel, and the subclass wants to override which panel to add, but it
> can't know what it needs to know in the override unless an init method
> has given it a chance to access PageParameters.
>
> -Clint
>
>
>
>
>>
>>
>> On Fri, May 15, 2009 at 12:01 AM, Vladimir K <ko...@gmail.com> wrote:
>>>
>>> Martijn,
>>>
>>> here Java is not safe as a language. Yo're able to invoke overrided methods
>>> on non-completely constructed objects.
>>>
>>> from my perspective it is a regular case in Wicket:
>>>
>>> class SampleComponent extends ... {
>>>    String parameter;
>>>
>>>    SampleComponent(String id, String parameter) {
>>>        super(id);
>>>        this.parameter = parameter;
>>>    }
>>>
>>>    // method is called from within superconstructor
>>>    @Override
>>>    void createAdditionalComponents(RepeatingView rv) {
>>>        useSomehow(parameter);
>>>    }
>>> }
>>>
>>> I know two approaches to work around:
>>> - onBeforeRender
>>> - a closure as a constructor formal parameter.
>>>
>>> But the latter does not help with built-in components.
>>>
>>> If Wicket does not help us with adding appropriate method for
>>> second-step-initialization it should document it in wiki, javadoc and books
>>> "dear user, when overriding methods, beware using of yet unassigned
>>> constructor parameters". Hmm ... sounds stupid :)
>>>
>>>
>>> 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 <ju...@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
>>>>> <da...@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-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
>
> --
> Clint Popetz
> http://42lines.net
> Scalable Web Application Development
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Clint Popetz <cl...@42lines.net>.
On Fri, May 15, 2009 at 12:07 AM, Jeremy Thomerson
<je...@wickettraining.com> wrote:
>
> Most java programmers know not to call overridable methods from the
> constructor as a general rule, although there are times when it could
> inadvertantly happen - which is why we need bug reports if you see
> that happening.
>

I've only been on the wicket  list for a few months, and I can
understand the annoyance of bringing up a subject that's perhaps been
beaten to death, but to me that means the resulting consensus to be
documented in the wiki, rather than pointing users to "search the
list."  So whatever comes out of this thread, I'll add it to the wiki
(unless it's already there, in which case I apologise.)

This isn't just a matter of whether Wicket internally calls
overridable methods.

What ends up happening (only in my experience) is that inheritance for
pages ends up needing you to create your own internal init() mechanism
in order to ensure that subclasses are ready to effectively override
methods for base class component creation.  I'm not suggesting that
Wicket provide this type of init() mechanism, but in my experience it
is a pattern that crops up, and it should be documented as such.  If
it is already documented, my apologies.  If it's an anti-pattern,
what's the alternative?


public class Template extends WebPage {
  public Template(PageParameters params) {
    setupParams(params);
    add(new Label("title",getTitle()));
  }

  pubilc void setupParams(PageParameters params) { }
  public String getTitle() { return "Title should be overriden"; }
}

public class SpecificPage extends Template {
  Object somethingCreatedBasedOnParams;
  public SpecificPage(PageParameters params) {
    super(params);
  }
  public void setupParams(PageParameters params) {
      //set up somethingCreatedBasedOnParams
  }
  public String getTitle() {
    return "A page about " + somethingCreatedBasedOnParams.getFoo();
  }
}

This same pattern evolves in my experience even if you are using
panels for templating, because you need the base class to add() the
panel, and the subclass wants to override which panel to add, but it
can't know what it needs to know in the override unless an init method
has given it a chance to access PageParameters.

-Clint




>
>
> On Fri, May 15, 2009 at 12:01 AM, Vladimir K <ko...@gmail.com> wrote:
>>
>> Martijn,
>>
>> here Java is not safe as a language. Yo're able to invoke overrided methods
>> on non-completely constructed objects.
>>
>> from my perspective it is a regular case in Wicket:
>>
>> class SampleComponent extends ... {
>>    String parameter;
>>
>>    SampleComponent(String id, String parameter) {
>>        super(id);
>>        this.parameter = parameter;
>>    }
>>
>>    // method is called from within superconstructor
>>    @Override
>>    void createAdditionalComponents(RepeatingView rv) {
>>        useSomehow(parameter);
>>    }
>> }
>>
>> I know two approaches to work around:
>> - onBeforeRender
>> - a closure as a constructor formal parameter.
>>
>> But the latter does not help with built-in components.
>>
>> If Wicket does not help us with adding appropriate method for
>> second-step-initialization it should document it in wiki, javadoc and books
>> "dear user, when overriding methods, beware using of yet unassigned
>> constructor parameters". Hmm ... sounds stupid :)
>>
>>
>> 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 <ju...@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
>>>> <da...@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-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Clint Popetz
http://42lines.net
Scalable Web Application Development

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Do you have any examples of where Wicket calls an overridable method
from the constructor of a Wicket class?  If so, please file it as a
JIRA - that would be a bug.

Most java programmers know not to call overridable methods from the
constructor as a general rule, although there are times when it could
inadvertantly happen - which is why we need bug reports if you see
that happening.

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




On Fri, May 15, 2009 at 12:01 AM, Vladimir K <ko...@gmail.com> wrote:
>
> Martijn,
>
> here Java is not safe as a language. Yo're able to invoke overrided methods
> on non-completely constructed objects.
>
> from my perspective it is a regular case in Wicket:
>
> class SampleComponent extends ... {
>    String parameter;
>
>    SampleComponent(String id, String parameter) {
>        super(id);
>        this.parameter = parameter;
>    }
>
>    // method is called from within superconstructor
>    @Override
>    void createAdditionalComponents(RepeatingView rv) {
>        useSomehow(parameter);
>    }
> }
>
> I know two approaches to work around:
> - onBeforeRender
> - a closure as a constructor formal parameter.
>
> But the latter does not help with built-in components.
>
> If Wicket does not help us with adding appropriate method for
> second-step-initialization it should document it in wiki, javadoc and books
> "dear user, when overriding methods, beware using of yet unassigned
> constructor parameters". Hmm ... sounds stupid :)
>
>
> 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 <ju...@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
>>> <da...@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-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Vladimir K <ko...@gmail.com>.
Martijn,

here Java is not safe as a language. Yo're able to invoke overrided methods
on non-completely constructed objects.

from my perspective it is a regular case in Wicket:

class SampleComponent extends ... {
    String parameter;

    SampleComponent(String id, String parameter) {
        super(id);
        this.parameter = parameter;
    }

    // method is called from within superconstructor
    @Override
    void createAdditionalComponents(RepeatingView rv) {
        useSomehow(parameter);
    }
}

I know two approaches to work around:
- onBeforeRender 
- a closure as a constructor formal parameter.

But the latter does not help with built-in components.

If Wicket does not help us with adding appropriate method for
second-step-initialization it should document it in wiki, javadoc and books
"dear user, when overriding methods, beware using of yet unassigned
constructor parameters". Hmm ... sounds stupid :)


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 <ju...@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
>> <da...@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-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Component-creation-and-initialization-tp23545666p23553458.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Martijn Dashorst <ma...@gmail.com>.
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 <ju...@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 <da...@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by "Juan G. Arias" <ju...@gmail.com>.
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 <da...@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Component creation and initialization

Posted by Daniel Stoch <da...@gmail.com>.
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Component creation and initialization

Posted by Jeremy Thomerson <je...@wickettraining.com>.
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




On Thu, May 14, 2009 at 12:51 PM, Juan G. Arias <ju...@gmail.com> wrote:
> Hi all,
> Is there a way in wicket for separate the object's instantiation phase from
> the inner component's creation phase?
> Just like the "init()" method in application, but for my components.
>
> Another way to see it, just in case it's not clear:
> Is there an already defined contract for component creation, that allows me
> to create the components I will use in some panel/page, but not to do it in
> the Java constructor?
>
> Thanks in advance!
> Juan
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org