but is a bit against our coding styles by creating the page in the
constructor
But i agree that works for now.
But multiple childs support would be very nice to have if it is just a
simple add on to the current way of doing.
But first lets i guess bring out 1.4 generics... (if i counted the votes
correctly)
johan
On Thu, Mar 20, 2008 at 10:19 AM, Igor Vaynberg <[EMAIL PROTECTED]>
wrote:
> the "workaround" is quiet easy
>
> class mypage extends webpage {
> onbeforerender() {
> if (get("panel1")==null) {
> add(newPanel1("panel1"));
> }
> super.onbeforerender();
> }
> }
>
> -igor
>
>
> On Thu, Mar 20, 2008 at 2:12 AM, Sebastiaan van Erk <[EMAIL PROTECTED]>
> wrote:
> > Gerolf Seitz wrote:
> > > you can provide factory methods in your base page like
> > > protected abstract Component newHeader(String id, IModel model);
> > >
> > > in the constructor of base page do:
> > > add(newHeader("header", someModelOrNull));
> > >
> > > and just override/implement the factory method in your concrete page
> > > classes.
> > >
> > > hth,
> > > Gerolf
> >
> >
> > I'll be so happy when multiple child is implemented, because I really
> > think this is an anti-pattern.
> >
> > Basically, in the constructor of the base page you call an overridable
> > method, which is terrible. For example you have in your subclass:
> >
> > public class MySubClass extends MyBaseClass {
> >
> > // my fields
> > public int answer = 42;
> >
> > public MySubClass(int suppliedAnswer) {
> > // implicit (or explicity call to super)
> > super();
> >
> > // init class state and establish class invariants
> > // this stuff could be really complicated!
> > if (suppliedAnswer != -1) {
> > answer = suppliedAnswer;
> > }
> > }
> >
> > @Override
> > public Component getUniverseComponent(String id) {
> > // create universe component using state of this class
> > // the structure of this component could depend on this
> > // the component could even depend on constructor
> > // args that the base class knows nothing about (as
> > // is the case now).
> > if (answer == 42) {
> > return new HHGTGPanel(id);
> > }
> > return new Label(id, String.valueOf(answer));
> > }
> >
> > }
> >
> > The problem is that getUniverseComponent gets called from the base
> class
> > before the constructor of the subclass gets evaluated. :-( This means
> > that the = 42 assignment has not been done yet, nor the override of the
> > value with the value from the constructor arg. The (partial) workaround
> > I've used (a special private init method and initialized flag) is just
> > plain ugly (and partial, since you still can't use your constructor
> args).
> >
> > Regards,
> > Sebastiaan
> >
> >
> >
> >
> > >
> > > On Thu, Mar 20, 2008 at 9:25 AM, Cristi Manole <
> [EMAIL PROTECTED]>
> > > wrote:
> > >
> > >> Hello,
> > >>
> > >> I've searched the web and I see there are a lot of hits for what I'm
> > >> looking
> > >> for but I cannot quite pinpoint the perfect solution (easiest) for
> this
> > >> simple thing.
> > >>
> > >> What I need is to be able to "extend" a base page and put into some
> places
> > >> some extra panels. I designed the places in the base page.
> > >>
> > >> For only one panel, I can use <wicket:child> tag. If I need more
> than one
> > >> panel inserted, how do I do that?
> > >>
> > >> Thanks,
> > >> Cristi Manole
> > >>
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>