You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Илья Нарыжный <ph...@ydn.ru> on 2016/08/19 06:29:39 UTC

Feature Request: Please add postConstruct() method

Hello,

There is a pain: components sometimes have a bunch of constructors, but
very often it's needed to configure something for that component in common.
And there are 2 ways to do that today:

1) Either explicitly call some single method from every constructor.
2) Or use onInitialize() method.

But both of them have disadvantages:

If first one has been used: it's pretty easy to forgot about necesity to
invoke some other method in some new constructor if you will need to add
that.

And second is not good because it's not possible to use constructions like
that in parent component:

add(new MyChildComponent("id", ....).setSomething(XXX));

because if "something" was set in onInitialize() - that will override
setting that param in code above.


Thanks,

Ilya

---------------------------------------------
Orienteer(http://orienteer.org) - open source Business Application Platform

Re: Feature Request: Please add postConstruct() method

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Wicket is not managed framework, i.e. it doesn't instantiate the components
for you.
You can use IComponentInstantiationListener in your application though!
If your component implements some custom interface then call its
#postConstruct().
I'm not convinced that each and every application needs this.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Aug 19, 2016 at 8:29 AM, Илья Нарыжный <ph...@ydn.ru> wrote:

> Hello,
>
> There is a pain: components sometimes have a bunch of constructors, but
> very often it's needed to configure something for that component in common.
> And there are 2 ways to do that today:
>
> 1) Either explicitly call some single method from every constructor.
> 2) Or use onInitialize() method.
>
> But both of them have disadvantages:
>
> If first one has been used: it's pretty easy to forgot about necesity to
> invoke some other method in some new constructor if you will need to add
> that.
>
> And second is not good because it's not possible to use constructions like
> that in parent component:
>
> add(new MyChildComponent("id", ....).setSomething(XXX));
>
> because if "something" was set in onInitialize() - that will override
> setting that param in code above.
>
>
> Thanks,
>
> Ilya
>
> ---------------------------------------------
> Orienteer(http://orienteer.org) - open source Business Application
> Platform
>