You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Arjun Dhar <dh...@yahoo.com> on 2016/02/18 07:21:09 UTC
Use a Factory to create a Panel (Yay or Nay)?
Hi,
I have a bunch of Admin panels but i want to be able to override them. The
issue is the pages obviously use "add(new SomeAdminPanel(....))";
To overcome this I was thinking or writing a Factory, that via can create
the desired instance of the Panel and pass it to the Page. The factory
internally can use Spring to make this highly configurable.
however, I came across
https://ci.apache.org/projects/wicket/guide/6.x/guide/bestpractices.html#bestpractices_12
(Do not use factories for components)
... can anyone validate if I should let that stop me from doing what I
intend? Maybe Panels are an exception to this rule?!
thanks
-----
Software documentation is like sex: when it is good, it is very, very good; and when it is bad, it is still better than nothing!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Use-a-Factory-to-create-a-Panel-Yay-or-Nay-tp4673622.html
Sent from the Users forum 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: Use a Factory to create a Panel (Yay or Nay)?
Posted by Patrick Davids <pa...@nubologic.com>.
> I have at times used factories and then found that they made some
simply things more complicated
I agree... you will loose the feature to sub-class and override
onConfigure() or onBeforeRender() of your components.
And what I also encountered using factories, when having sub-classed
model-objects and you want to choose as specific component depending on
the model-objects subclass, you run into the "unpack on construction
time" issue, which is also not that good.
And if you want to use shared models for your components and forward
your model to your via factory constructed component, you will get type
safety warnings.
e.g. factoryMethod(IModel<Person> personModel){
if(personModel.getObject() instanceof Employee){
return new EmployeePanel((IModel<Employee>)personModel);//type safety
warning
}else{
...
}
}
All this points are somehow "code smells" to me and from the experience
of the last years I more and more agree with the "bad practice" not to
use factories for components.
But I never used Spring / SpringFactories... maybe you wont run into the
described issues... not sure here.
best regards
Patrick
Am 18.02.2016 um 10:12 schrieb Urbani, Edmund:
> Hello,
>
> I have at times used factories and then found that they made some simply
> things more complicated. Eg. I could no longer simply override
> isEnabled() or isVisible() methods to suit the page I was added the
> component to. So I try to avoid factories for Wicket components now
> unless I see a real advantage.
>
> Kind regards,
> Edmund
>
> On 02/18/2016 09:53 AM, Sven Meier wrote:
>> Hi,
>>
>> I wouldn't use a factory for each and every component (e.g. label).
>> But any sufficiently large Wicket project will benefit from separating
>> it into separate parts which very light interdependencies only: a
>> plugin-based architecture.
>>
>> If you're using Spring factories, you just have to take care that no
>> references to Spring beans leak into the components - something you
>> have easily with inner classes (as in the example listing 15 in the
>> Wicket guide).
>>
>> Have fun
>> Sven
>>
>>
>> On 18.02.2016 09:01, Martin Grigorov wrote:
>>> Hi,
>>>
>>> I don't share the option in the guide.
>>> Using factories when needed is perfectly fine.
>>> Apache Isis uses factories to provide custom UI for almost any part
>>> of the
>>> Wicket viewer.
>>> BrixCMS also uses factories to create tiles.
>>>
>>> Martin Grigorov
>>> Wicket Training and Consulting
>>> https://twitter.com/mtgrigorov
>>>
>>> On Thu, Feb 18, 2016 at 7:21 AM, Arjun Dhar <dh...@yahoo.com> wrote:
>>>
>>>> Hi,
>>>> I have a bunch of Admin panels but i want to be able to override
>>>> them. The
>>>> issue is the pages obviously use "add(new SomeAdminPanel(....))";
>>>>
>>>> To overcome this I was thinking or writing a Factory, that via can
>>>> create
>>>> the desired instance of the Panel and pass it to the Page. The factory
>>>> internally can use Spring to make this highly configurable.
>>>>
>>>> however, I came across
>>>>
>>>> https://ci.apache.org/projects/wicket/guide/6.x/guide/bestpractices.html#bestpractices_12
>>>>
>>>> (Do not use factories for components)
>>>>
>>>> ... can anyone validate if I should let that stop me from doing what I
>>>> intend? Maybe Panels are an exception to this rule?!
>>>>
>>>> thanks
>>>>
>>>> -----
>>>> Software documentation is like sex: when it is good, it is very, very
>>>> good; and when it is bad, it is still better than nothing!
>>>> --
>>>> View this message in context:
>>>> http://apache-wicket.1842946.n4.nabble.com/Use-a-Factory-to-create-a-Panel-Yay-or-Nay-tp4673622.html
>>>>
>>>> Sent from the Users forum 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
>>
>
>
> --
>
> Mit freundlichen Grüßen
> Edmund Urbani
> Liland IT Team
>
> Email: <ma...@lilandit.com>Edmund.Urbani@Lilandit.com
>
> Liland IT GmbH ...does IT better
> Tel: +43 463 220111
> Fax: +43 463 220111-33
> Tel(GER): +49 221 65028588
>
> Find us at Facebook http://facebook.com/Lilandit
> http://green-badges.com
> http://iventcloud.com
> http://Lilandit.com
>
> <http://www.LilandIT.com> <http://www.LilandIT.com>
>
> Copyright © 2016, Liland IT GmbH
>
> Diese Mail enthaelt vertrauliche und/oder rechtlich geschuetzte
> Informationen.
> Wenn Sie nicht der richtige Adressat sind oder diese Email irrtuemlich
> erhalten haben, informieren Sie bitte sofort den Absender und vernichten
> Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe
> dieser Mail ist nicht gestattet.
>
> This email may contain confidential and/or privileged information.
> If you are not the intended recipient (or have received this email in
> error) please notify the sender immediately and destroy this email. Any
> unauthorised copying, disclosure or distribution of the material in this
> email is strictly forbidden.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Use a Factory to create a Panel (Yay or Nay)?
Posted by Sven Meier <sv...@meiers.net>.
Hi,
read here:
http://wicketinaction.com/2011/11/implement-wicket-component-visibility-changes-properly/
Sven
On 21.02.2016 12:40, Peter Henderson wrote:
> On Thu, Feb 18, 2016 at 9:15 AM, Martin Grigorov <mg...@apache.org>
> wrote:
>
>> On Thu, Feb 18, 2016 at 10:12 AM, Urbani, Edmund <
>> edmund.urbani@lilandit.com
>>> wrote:
>>> Hello,
>>>
>>> I have at times used factories and then found that they made some simply
>>> things more complicated. Eg. I could no longer simply override
>> isEnabled()
>>> or isVisible() methods to suit the page I was
>>>
>> Overriding isVisible/isEnabled() is a bad idea anyway!
>> Use onConfigure() + setVisible/setEnabled instead.
>>
>
> Oh dear, I override isVisible/isEnabled quite a lot.
> Why is it considered a bad idea?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Use a Factory to create a Panel (Yay or Nay)?
Posted by Peter Henderson <pe...@starjar.com>.
On Thu, Feb 18, 2016 at 9:15 AM, Martin Grigorov <mg...@apache.org>
wrote:
> On Thu, Feb 18, 2016 at 10:12 AM, Urbani, Edmund <
> edmund.urbani@lilandit.com
> > wrote:
>
> > Hello,
> >
> > I have at times used factories and then found that they made some simply
> > things more complicated. Eg. I could no longer simply override
> isEnabled()
> > or isVisible() methods to suit the page I was
> >
>
> Overriding isVisible/isEnabled() is a bad idea anyway!
> Use onConfigure() + setVisible/setEnabled instead.
>
Oh dear, I override isVisible/isEnabled quite a lot.
Why is it considered a bad idea?
Re: Use a Factory to create a Panel (Yay or Nay)?
Posted by Martin Grigorov <mg...@apache.org>.
On Thu, Feb 18, 2016 at 10:12 AM, Urbani, Edmund <edmund.urbani@lilandit.com
> wrote:
> Hello,
>
> I have at times used factories and then found that they made some simply
> things more complicated. Eg. I could no longer simply override isEnabled()
> or isVisible() methods to suit the page I was
>
Overriding isVisible/isEnabled() is a bad idea anyway!
Use onConfigure() + setVisible/setEnabled instead.
> added the component to. So I try to avoid factories for Wicket components
> now unless I see a real advantage.
>
> Kind regards,
> Edmund
>
>
> On 02/18/2016 09:53 AM, Sven Meier wrote:
>
> Hi,
>
> I wouldn't use a factory for each and every component (e.g. label).
> But any sufficiently large Wicket project will benefit from separating it
> into separate parts which very light interdependencies only: a plugin-based
> architecture.
>
> If you're using Spring factories, you just have to take care that no
> references to Spring beans leak into the components - something you have
> easily with inner classes (as in the example listing 15 in the Wicket
> guide).
>
> Have fun
> Sven
>
>
> On 18.02.2016 09:01, Martin Grigorov wrote:
>
> Hi,
>
> I don't share the option in the guide.
> Using factories when needed is perfectly fine.
> Apache Isis uses factories to provide custom UI for almost any part of the
> Wicket viewer.
> BrixCMS also uses factories to create tiles.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Thu, Feb 18, 2016 at 7:21 AM, Arjun Dhar <dh...@yahoo.com>
> <dh...@yahoo.com> wrote:
>
> Hi,
> I have a bunch of Admin panels but i want to be able to override them. The
> issue is the pages obviously use "add(new SomeAdminPanel(....))";
>
> To overcome this I was thinking or writing a Factory, that via can create
> the desired instance of the Panel and pass it to the Page. The factory
> internally can use Spring to make this highly configurable.
>
> however, I came across
>
>
> https://ci.apache.org/projects/wicket/guide/6.x/guide/bestpractices.html#bestpractices_12
> (Do not use factories for components)
>
> ... can anyone validate if I should let that stop me from doing what I
> intend? Maybe Panels are an exception to this rule?!
>
> thanks
>
> -----
> Software documentation is like sex: when it is good, it is very, very
> good; and when it is bad, it is still better than nothing!
> --
> View this message in context:
>
> http://apache-wicket.1842946.n4.nabble.com/Use-a-Factory-to-create-a-Panel-Yay-or-Nay-tp4673622.html
> Sent from the Users forum 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
>
>
>
> --
>
> Mit freundlichen Grüßen
> Edmund Urbani
> Liland IT Team
>
> Email: <Ed...@lilandit.com>Edmund.Urbani@Lilandit.com
>
> Liland IT GmbH ...does IT better
> Tel: +43 463 220111
> Fax: +43 463 220111-33
> Tel(GER): +49 221 65028588
>
> Find us at Facebook http://facebook.com/Lilandit
> http://green-badges.com
> http://iventcloud.com
> http://Lilandit.com
>
> <http://www.LilandIT.com> <http://www.LilandIT.com>
>
> Copyright © 2016, Liland IT GmbH
>
> Diese Mail enthaelt vertrauliche und/oder rechtlich geschuetzte
> Informationen.
> Wenn Sie nicht der richtige Adressat sind oder diese Email irrtuemlich
> erhalten haben, informieren Sie bitte sofort den Absender und vernichten
> Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe
> dieser Mail ist nicht gestattet.
>
> This email may contain confidential and/or privileged information.
> If you are not the intended recipient (or have received this email in
> error) please notify the sender immediately and destroy this email. Any
> unauthorised copying, disclosure or distribution of the material in this
> email is strictly forbidden.
>
Re: Use a Factory to create a Panel (Yay or Nay)?
Posted by "Urbani, Edmund" <ed...@lilandit.com>.
Hello,
I have at times used factories and then found that they made some simply things
more complicated. Eg. I could no longer simply override isEnabled() or
isVisible() methods to suit the page I was added the component to. So I try to
avoid factories for Wicket components now unless I see a real advantage.
Kind regards,
Edmund
On 02/18/2016 09:53 AM, Sven Meier wrote:
> Hi,
>
> I wouldn't use a factory for each and every component (e.g. label).
> But any sufficiently large Wicket project will benefit from separating it into
> separate parts which very light interdependencies only: a plugin-based
> architecture.
>
> If you're using Spring factories, you just have to take care that no
> references to Spring beans leak into the components - something you have
> easily with inner classes (as in the example listing 15 in the Wicket guide).
>
> Have fun
> Sven
>
>
> On 18.02.2016 09:01, Martin Grigorov wrote:
>> Hi,
>>
>> I don't share the option in the guide.
>> Using factories when needed is perfectly fine.
>> Apache Isis uses factories to provide custom UI for almost any part of the
>> Wicket viewer.
>> BrixCMS also uses factories to create tiles.
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>> https://twitter.com/mtgrigorov
>>
>> On Thu, Feb 18, 2016 at 7:21 AM, Arjun Dhar <dh...@yahoo.com> wrote:
>>
>>> Hi,
>>> I have a bunch of Admin panels but i want to be able to override them. The
>>> issue is the pages obviously use "add(new SomeAdminPanel(....))";
>>>
>>> To overcome this I was thinking or writing a Factory, that via can create
>>> the desired instance of the Panel and pass it to the Page. The factory
>>> internally can use Spring to make this highly configurable.
>>>
>>> however, I came across
>>>
>>> https://ci.apache.org/projects/wicket/guide/6.x/guide/bestpractices.html#bestpractices_12
>>>
>>> (Do not use factories for components)
>>>
>>> ... can anyone validate if I should let that stop me from doing what I
>>> intend? Maybe Panels are an exception to this rule?!
>>>
>>> thanks
>>>
>>> -----
>>> Software documentation is like sex: when it is good, it is very, very
>>> good; and when it is bad, it is still better than nothing!
>>> --
>>> View this message in context:
>>> http://apache-wicket.1842946.n4.nabble.com/Use-a-Factory-to-create-a-Panel-Yay-or-Nay-tp4673622.html
>>>
>>> Sent from the Users forum 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
>
--
Mit freundlichen Grüßen
Edmund Urbani
Liland IT Team
Email: Edmund.Urbani@Lilandit.com <ma...@lilandit.com>
Liland IT GmbH ...does IT better
Tel: +43 463 220111
Fax: +43 463 220111-33
Tel(GER): +49 221 65028588
Find us at Facebook http://facebook.com/Lilandit
http://green-badges.com
http://iventcloud.com
http://Lilandit.com
<http://www.LilandIT.com> <http://www.LilandIT.com>
Copyright © 2016, Liland IT GmbH
Diese Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese Email irrtuemlich erhalten
haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht
gestattet.
This email may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this email in error)
please notify the sender immediately and destroy this email. Any unauthorised
copying, disclosure or distribution of the material in this email is strictly
forbidden.
Re: Use a Factory to create a Panel (Yay or Nay)?
Posted by Sven Meier <sv...@meiers.net>.
Hi,
I wouldn't use a factory for each and every component (e.g. label).
But any sufficiently large Wicket project will benefit from separating
it into separate parts which very light interdependencies only: a
plugin-based architecture.
If you're using Spring factories, you just have to take care that no
references to Spring beans leak into the components - something you have
easily with inner classes (as in the example listing 15 in the Wicket
guide).
Have fun
Sven
On 18.02.2016 09:01, Martin Grigorov wrote:
> Hi,
>
> I don't share the option in the guide.
> Using factories when needed is perfectly fine.
> Apache Isis uses factories to provide custom UI for almost any part of the
> Wicket viewer.
> BrixCMS also uses factories to create tiles.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Thu, Feb 18, 2016 at 7:21 AM, Arjun Dhar <dh...@yahoo.com> wrote:
>
>> Hi,
>> I have a bunch of Admin panels but i want to be able to override them. The
>> issue is the pages obviously use "add(new SomeAdminPanel(....))";
>>
>> To overcome this I was thinking or writing a Factory, that via can create
>> the desired instance of the Panel and pass it to the Page. The factory
>> internally can use Spring to make this highly configurable.
>>
>> however, I came across
>>
>> https://ci.apache.org/projects/wicket/guide/6.x/guide/bestpractices.html#bestpractices_12
>> (Do not use factories for components)
>>
>> ... can anyone validate if I should let that stop me from doing what I
>> intend? Maybe Panels are an exception to this rule?!
>>
>> thanks
>>
>> -----
>> Software documentation is like sex: when it is good, it is very, very
>> good; and when it is bad, it is still better than nothing!
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Use-a-Factory-to-create-a-Panel-Yay-or-Nay-tp4673622.html
>> Sent from the Users forum 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: Use a Factory to create a Panel (Yay or Nay)?
Posted by Arjun Dhar <dh...@yahoo.com>.
Thanks martin for the validation. Just to add to the group discussion, when
developing a CMS (esp for E-Commerce) you do want other developers to at
some point override any default Panels in your base UI with their own
Plugin-ins. .. that was my intent.
Even if someone feels factories are not a good idea, I request an alternate.
Though, I feel it looks good as a solution and nice to have some validation.
thanks
-----
Software documentation is like sex: when it is good, it is very, very good; and when it is bad, it is still better than nothing!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Use-a-Factory-to-create-a-Panel-Yay-or-Nay-tp4673622p4673642.html
Sent from the Users forum 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: Use a Factory to create a Panel (Yay or Nay)?
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
I don't share the option in the guide.
Using factories when needed is perfectly fine.
Apache Isis uses factories to provide custom UI for almost any part of the
Wicket viewer.
BrixCMS also uses factories to create tiles.
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Thu, Feb 18, 2016 at 7:21 AM, Arjun Dhar <dh...@yahoo.com> wrote:
> Hi,
> I have a bunch of Admin panels but i want to be able to override them. The
> issue is the pages obviously use "add(new SomeAdminPanel(....))";
>
> To overcome this I was thinking or writing a Factory, that via can create
> the desired instance of the Panel and pass it to the Page. The factory
> internally can use Spring to make this highly configurable.
>
> however, I came across
>
> https://ci.apache.org/projects/wicket/guide/6.x/guide/bestpractices.html#bestpractices_12
> (Do not use factories for components)
>
> ... can anyone validate if I should let that stop me from doing what I
> intend? Maybe Panels are an exception to this rule?!
>
> thanks
>
> -----
> Software documentation is like sex: when it is good, it is very, very
> good; and when it is bad, it is still better than nothing!
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Use-a-Factory-to-create-a-Panel-Yay-or-Nay-tp4673622.html
> Sent from the Users forum 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
>
>