Yes, that's a decorator pattern, which could a be good practice. You don't
use inheritance since you've just got a Panel, not a Page. So feel free to
go for that solution, I find it smart, too.



On Wed, Dec 8, 2010 at 7:51 AM, Jeremy Thomerson
<[email protected]>wrote:

> On Tue, Dec 7, 2010 at 4:08 AM, Peter Karich <[email protected]> wrote:
> > regarding the panels: I'm using a lot of them. But for instantiation I
> need
> > to
> > specify what to do onClick so I could reuse the panel in a different
> context
> > somewhen later.
> > I mean, when the panelA detects a click this is forwarded to the onClick
> > method which is overwritten in Homepage to invoke a search.
> > But if I want to reuse that panelA in a different context maybe I want to
> > trigger a different onClick behaviour?
>
> You can use this pattern of creating extension points:
>
> class MyPanel extends Panel {
>  MyPanel(id) {
>    super(id);
>    add(new Link<Void>("foo") {
>      public void onClick() {
>        onFooLinkClicked();
>      }
>    });
>  }
>
>  protected void onFooLinkClicked() { /* this method is designed to be
> overridden */ }
> }
>
>
> class SomePage extends YourBasePage {
>  SomePage() {
>    add(new MyPanel("bar") {
>      protected void onFooLinkClicked() {
>        // put your page-specific logic here.
>      }
>    });
>  }
> }
>
> --
> Jeremy Thomerson
> http://wickettraining.com
> Need a CMS for Wicket?  Use Brix! http://brixcms.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Sans ami était le grand maître des mondes
Eprouvait manque, ce pourquoi il créa les Esprits.
Mais au vrai il ne trouva aucun égal,
Du calice de ce royaume total des âmes
Ecume jusqu'à lui L'Infinité.

Schiller, "l'amitié"

Reply via email to