Re: Multiple wicket:child/ panels like behaviour

2008-03-20 Thread Gerolf Seitz
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

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



Re: Multiple wicket:child/ panels like behaviour

2008-03-20 Thread Johan Compagner
This is planned for the next release (not the genrerics only release
if that will be the 1.4)

On 3/20/08, 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]



Re: Multiple wicket:child/ panels like behaviour

2008-03-20 Thread Sebastiaan van Erk

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





smime.p7s
Description: S/MIME Cryptographic Signature


Re: Multiple wicket:child/ panels like behaviour

2008-03-20 Thread Gerolf Seitz
i agree with you. i had to fight similar problems and came up with
similar (ugly) work arounds.
let's see how the post-1.4 solution works out ;)

  Gerolf

On Thu, Mar 20, 2008 at 10: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
 
 



Re: Multiple wicket:child/ panels like behaviour

2008-03-20 Thread Igor Vaynberg
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]



Re: Multiple wicket:child/ panels like behaviour

2008-03-20 Thread Johan Compagner
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]




Re: Multiple wicket:child/ panels like behaviour

2008-03-20 Thread Sebastiaan van Erk

Yes, Johan told me about that one. :-)

But I really think that's quite ugly too... :( I really don't want to 
add hooks to do something that is just regular initialization of the 
component hierarchy of the page... And whenever possible I think my 
other work around is at least more intuitive...


Regards,
Sebastiaan


Igor Vaynberg 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]



smime.p7s
Description: S/MIME Cryptographic Signature