Re: Constructors take vararg of Component? (Enhancement RFC)

2013-01-07 Thread Martin Grigorov
Hi,

The component constructor doesn't call #add() at the moment (and I think
this wont change soon without a better reason).
So even if adding the varargs this wont help.

But you can create your own components which do this:

public class MyForm extends FormEntity {
   public MyForm(String id, IModelEntity model, Component... children) {
 super(id, model);

 ad(children);
   }
}


On Sun, Jan 6, 2013 at 9:24 PM, Zac Bedell zacl...@thebedells.org wrote:

 Greetings all,

 I was wondering what Wicket users  devs might thing of a possible API
 change for a future version (maybe Wicket 7?) of including a varargs array
 of Component as the final parameter of all of the various MarkupContainer
 subclasses?  I find myself doing things like these a lot:

 pnlNoRsvp = new WebMarkupContainer(pnlNoRsvp);
 pnlRsvp = new StatusPanel(pnlRsvp);
 pnlConfirm = new ConfirmPanel(pnlConfirm);
 pnlRsvpRules = new RsvpRulesPanel(pnlRsvpRules);

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 new FormRsvpPage(frmRsvp, cpm) {
   {
 add(pnlNoRsvp, pnlRsvp, pnlConfirm);
   }
 },
 pnlRsvpRules
 );

 -- or --

 FormRsvpPage frmRsvp = new FormRsvpPage(frmRsvp, cpm);
 frmRsvp.add(pnlNoRsvp, pnlRsvp, pnlConfirm);

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 frmRsvp,
 pnlRsvpRules
 );

 --

 If Form and the various other Wicket MarkupContainer's had constructors
 with Component... as their final parameter, it would be possible to do
 something like:

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 new FormRsvpPage(frmRsvp, cpm, pnlNoRsvp, pnlRsvp, pnlConfirm),
 pnlRsvpRules
 );

 --

 Granted, this would balloon the number of constructors throughout the
 framework just to save a bit of typing.  Curious what others might think...

 Best regards,
 Zac Bedell
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com http://jweekend.com/


Re: Constructors take vararg of Component? (Enhancement RFC)

2013-01-07 Thread Jochen Mader
Why aren't you using fluent interfaces?
The API ist built around that and allows for a much cleaner structure
inside your constructors.
Just watch out for those Auto-Formaters ;)

new FormRsvpPage(frmRsvp, cpm)
.add(new StatusPanel(pnlRsvp))
.add(new ConfirmPanel(pnlConfirm))
.add(new RsvpRulesPanel(pnlRsvpRules));


On Mon, Jan 7, 2013 at 9:17 AM, Martin Grigorov mgrigo...@apache.org wrote:
 Hi,

 The component constructor doesn't call #add() at the moment (and I think
 this wont change soon without a better reason).
 So even if adding the varargs this wont help.

 But you can create your own components which do this:

 public class MyForm extends FormEntity {
public MyForm(String id, IModelEntity model, Component... children) {
  super(id, model);

  ad(children);
}
 }


 On Sun, Jan 6, 2013 at 9:24 PM, Zac Bedell zacl...@thebedells.org wrote:

 Greetings all,

 I was wondering what Wicket users  devs might thing of a possible API
 change for a future version (maybe Wicket 7?) of including a varargs array
 of Component as the final parameter of all of the various MarkupContainer
 subclasses?  I find myself doing things like these a lot:

 pnlNoRsvp = new WebMarkupContainer(pnlNoRsvp);
 pnlRsvp = new StatusPanel(pnlRsvp);
 pnlConfirm = new ConfirmPanel(pnlConfirm);
 pnlRsvpRules = new RsvpRulesPanel(pnlRsvpRules);

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 new FormRsvpPage(frmRsvp, cpm) {
   {
 add(pnlNoRsvp, pnlRsvp, pnlConfirm);
   }
 },
 pnlRsvpRules
 );

 -- or --

 FormRsvpPage frmRsvp = new FormRsvpPage(frmRsvp, cpm);
 frmRsvp.add(pnlNoRsvp, pnlRsvp, pnlConfirm);

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 frmRsvp,
 pnlRsvpRules
 );

 --

 If Form and the various other Wicket MarkupContainer's had constructors
 with Component... as their final parameter, it would be possible to do
 something like:

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 new FormRsvpPage(frmRsvp, cpm, pnlNoRsvp, pnlRsvp, pnlConfirm),
 pnlRsvpRules
 );

 --

 Granted, this would balloon the number of constructors throughout the
 framework just to save a bit of typing.  Curious what others might think...

 Best regards,
 Zac Bedell
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com http://jweekend.com/

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Constructors take vararg of Component? (Enhancement RFC)

2013-01-06 Thread Robert Szmurlo

Hi,

you can use something like this:

RsvpPage.this.add(
new Label(event.title),
new CssFeedbackPanel(feedback),
new FormRsvpPage(frmRsvp, cpm).add(pnlNoRsvp, pnlRsvp, pnlConfirm),
pnlRsvpRules
);

I am not dev, but I wouldn't break the API.

BR,
Robert Szmurlo

W dniu 2013-01-06 20:24, Zac Bedell pisze:

Greetings all,

I was wondering what Wicket users  devs might thing of a possible API change 
for a future version (maybe Wicket 7?) of including a varargs array of Component as 
the final parameter of all of the various MarkupContainer subclasses?  I find 
myself doing things like these a lot:

 pnlNoRsvp = new WebMarkupContainer(pnlNoRsvp);
 pnlRsvp = new StatusPanel(pnlRsvp);
 pnlConfirm = new ConfirmPanel(pnlConfirm);
 pnlRsvpRules = new RsvpRulesPanel(pnlRsvpRules);

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 new FormRsvpPage(frmRsvp, cpm) {
   {
 add(pnlNoRsvp, pnlRsvp, pnlConfirm);
   }
 },
 pnlRsvpRules
 );

-- or --
 
 FormRsvpPage frmRsvp = new FormRsvpPage(frmRsvp, cpm);

 frmRsvp.add(pnlNoRsvp, pnlRsvp, pnlConfirm);

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 frmRsvp,
 pnlRsvpRules
 );

--

If Form and the various other Wicket MarkupContainer's had constructors with 
Component... as their final parameter, it would be possible to do something 
like:

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 new FormRsvpPage(frmRsvp, cpm, pnlNoRsvp, pnlRsvp, pnlConfirm),
 pnlRsvpRules
 );

--

Granted, this would balloon the number of constructors throughout the framework 
just to save a bit of typing.  Curious what others might think...

Best regards,
Zac Bedell
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org