On Tue, May 8, 2018 at 5:11 PM, Korbinian Bachl <
korbinian.ba...@whiskyworld.de> wrote:

>
>
> ----- Urspr√ľngliche Mail -----
> >
> >> But how does it go for the lifecycle of a component on a page where the
> >> page gets submitted by a form in another component?
> >>
> >
> > I do not understand this sentence
>
>
> It may sound a bit awkward but the situation is like this:
>
> Page with componentes A, B, C, D on it
> Component A is just an resolver that fills a request scoped CDI with
> decoded data for components B,C,D in its constructor
> Component B,C,D now reacts onto these data from Component A in the
> onBeforeRender method
>
> all is fine if its not rerendered like it was used some years now (code
> stems from looong time ago :/ )
>
> now I introduced an form into component D and there the mess began as A's
> construtor didnt get called again as its page was already rendered...
>
> this was all made before wicket had the current lifecycle as well as the
> methods that get invoked we have today in wicket 7 and 8;
>

The Request*Cycle* has been re-worked in Wicket 1.5.
Some new methods have been added to the Component lifecycle - onInitialize
and onConfigure.
But Component's constructor has been called just *once* (for a stateful
page!) since I know Wicket (around early days of Wicket 1.3).

If the page is *stateless* then the page and its complete component tree
will be re-created, i.e. their constructors will be called on each request.


>
>
> >
> >>
> >
> > onConfigure() and onDetach() are called at every request
> > if the component is visible then onBeforeRender, onRender() and
> > onAfterRender() will be called too
>
> Ah ok,
>
> So is it correct if I assume that onConfigure gets called in the same
> order as the components get added to the page and in that order on each
> re-render?
>
> What would be the best way in 2018 to have decoupled components that share
> logic?
>

The same as 10 years ago, I'd say.
With Java 8 you can have interfaces with default impls but all other ways
for sharing logic between several classes are pretty old.
If you use more modern JVM languages then the options are bigger.
If you ask for Wicket specific ways again it is the same as before - you
can use Behavior to share common logic between Components.


>
>
> Best,
>
> KB
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to