You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris Colman <ch...@stepaheadsoftware.com> on 2011/04/11 15:08:12 UTC

Form composed of Panel components

I have a complex form that I choose to break down into logical sub Panel
components and then add them as children to the Form.
 
The sub Panels themselves then have FormComponents like text fields and
DropDownChoice components added to them. Will the normal validate/update
mechanism simply work like that or do I need to override some methods in
my Panel classes or make the Panel classes implement certain interfaces
(eg., IFormVisitorParticipant etc.,)?
 
Chris Colman
 

Re: Form composed of Panel components

Posted by Michael O'Cleirigh <mi...@rivulet.ca>.
Extending FormComponentPanel is useful if you want your panel to return 
some IModel<BusinessObject> that is built from the various controls on 
the page.

You can override convertInput and onBeforeRender to build/show the 
BusinessObject into the panel fields.

It can make things a lot simpler because the validation logic is lower 
(on the custom panels) so the form processing logic can work on just the 
BusinessObject's themselves.


For example:

class MyBusinessObjectPanel extends FormComponentPanel<BusinessObject> {

     private TextField nameField;

     private Calendar cal;

  ... skipping constructor, etc ...
@Override
     protected void convertInput() {

         nameField.processInput();

         cal.processInput();

         String name = nameField.getModel().getObject();

         DateTime date = cal.getModel().getObject();

         setConvertedInput (new  BusinessObject (name, date));


     }

@Override
     protected void onBeforeRender() {

         BusinessObject bo = getModelObject();

         nameField.setModelObject(bo.getName());

         cal.setModelObject(bo.getDate());

         super.onBeforeRender();

     }


Notice how the inner components of the panel don't use a property or 
field wise model but instead are simply a string model and a datetime model?

This allows the current value of the panel's model object to be 
protected.  The convertedValue object is what the validation 
infrastructure validates (if ok then it becomes the model object).

I've found this is the best way to handle really complex forms and 
properly internalize their operations.

Regards,

Mike


> Simply nestle sub Panel contain form components is fine if you make sure
> that there are a form component higher in hierarchy. FormComponentPanel is
> useful if you want the panel itself participating in form processing, I
> don't think this is the case.
>
> On Mon, Apr 11, 2011 at 10:08 AM, Chris Colman<chrisc@stepaheadsoftware.com
>> wrote:
>> I have a complex form that I choose to break down into logical sub Panel
>> components and then add them as children to the Form.
>>
>> The sub Panels themselves then have FormComponents like text fields and
>> DropDownChoice components added to them. Will the normal validate/update
>> mechanism simply work like that or do I need to override some methods in
>> my Panel classes or make the Panel classes implement certain interfaces
>> (eg., IFormVisitorParticipant etc.,)?
>>
>> Chris Colman
>>
>>
>


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


Re: Form composed of Panel components

Posted by Pedro Santos <pe...@gmail.com>.
Simply nestle sub Panel contain form components is fine if you make sure
that there are a form component higher in hierarchy. FormComponentPanel is
useful if you want the panel itself participating in form processing, I
don't think this is the case.

On Mon, Apr 11, 2011 at 10:08 AM, Chris Colman <chrisc@stepaheadsoftware.com
> wrote:

> I have a complex form that I choose to break down into logical sub Panel
> components and then add them as children to the Form.
>
> The sub Panels themselves then have FormComponents like text fields and
> DropDownChoice components added to them. Will the normal validate/update
> mechanism simply work like that or do I need to override some methods in
> my Panel classes or make the Panel classes implement certain interfaces
> (eg., IFormVisitorParticipant etc.,)?
>
> Chris Colman
>
>


-- 
Pedro Henrique Oliveira dos Santos

Re: Form composed of Panel components

Posted by Pedro Santos <pe...@gmail.com>.
Yes if you implement IFormModelUpdateListener and add a form validator in
form.

On Mon, Apr 11, 2011 at 11:01 AM, Chris Colman <chrisc@stepaheadsoftware.com
> wrote:

> What if I want the Panel containers to have their own updateModel and
> validate methods? Will those methods be called on a class I derive from
> Panel?
>
> >-----Original Message-----
> >From: Pedro Santos [mailto:pedrosans@gmail.com]
> >Sent: Monday, 11 April 2011 11:54 PM
> >To: users@wicket.apache.org
> >Subject: Re: Form composed of Panel components
> >
> >Form will process nested form components regardless of the web markup
> >container component you used to group them.
> >
> >On Mon, Apr 11, 2011 at 10:46 AM, Chris Colman
> ><chrisc@stepaheadsoftware.com
> >> wrote:
> >
> >> I can't derive my Panels from FormComponentPanel because a strict
> >> inheritance hierarchy of Panels is already in place. I've started
> >> playing around with the Panels in question implementing
> >> IFormVisitorParticipant and IFormModelUpdateListener and this seems
> to
> >> be at least calling the validate and updateModel methods in my Panels
> >> now - I think plain vanilla Panels are ignored by the Form processing
> >> mechanism unless they implement these interfaces?
> >>
> >> >-----Original Message-----
> >> >From: Wilhelmsen Tor Iver [mailto:TorIverW@arrive.no]
> >> >Sent: Monday, 11 April 2011 11:11 PM
> >> >To: users@wicket.apache.org
> >> >Subject: RE: Form composed of Panel components
> >> >
> >> >Look into org.apache.wicket.markup.html.form.FormComponentPanel<T>
> >> >
> >> >- Tor Iver
> >> >
> >> >-----Original Message-----
> >> >From: Chris Colman [mailto:chrisc@stepaheadsoftware.com]
> >> >Sent: 11. april 2011 15:08
> >> >To: users@wicket.apache.org
> >> >Subject: Form composed of Panel components
> >> >
> >> >I have a complex form that I choose to break down into logical sub
> >> Panel
> >> >components and then add them as children to the Form.
> >> >
> >> >The sub Panels themselves then have FormComponents like text fields
> and
> >> >DropDownChoice components added to them. Will the normal
> >> validate/update
> >> >mechanism simply work like that or do I need to override some
> methods
> >> in
> >> >my Panel classes or make the Panel classes implement certain
> interfaces
> >> >(eg., IFormVisitorParticipant etc.,)?
> >> >
> >> >Chris Colman
> >> >
> >> >
> >>
> >---------------------------------------------------------------------
> >> >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
> >>
> >>
> >
> >
> >--
> >Pedro Henrique Oliveira dos Santos
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos

RE: Form composed of Panel components

Posted by Chris Colman <ch...@stepaheadsoftware.com>.
What if I want the Panel containers to have their own updateModel and
validate methods? Will those methods be called on a class I derive from
Panel?

>-----Original Message-----
>From: Pedro Santos [mailto:pedrosans@gmail.com]
>Sent: Monday, 11 April 2011 11:54 PM
>To: users@wicket.apache.org
>Subject: Re: Form composed of Panel components
>
>Form will process nested form components regardless of the web markup
>container component you used to group them.
>
>On Mon, Apr 11, 2011 at 10:46 AM, Chris Colman
><chrisc@stepaheadsoftware.com
>> wrote:
>
>> I can't derive my Panels from FormComponentPanel because a strict
>> inheritance hierarchy of Panels is already in place. I've started
>> playing around with the Panels in question implementing
>> IFormVisitorParticipant and IFormModelUpdateListener and this seems
to
>> be at least calling the validate and updateModel methods in my Panels
>> now - I think plain vanilla Panels are ignored by the Form processing
>> mechanism unless they implement these interfaces?
>>
>> >-----Original Message-----
>> >From: Wilhelmsen Tor Iver [mailto:TorIverW@arrive.no]
>> >Sent: Monday, 11 April 2011 11:11 PM
>> >To: users@wicket.apache.org
>> >Subject: RE: Form composed of Panel components
>> >
>> >Look into org.apache.wicket.markup.html.form.FormComponentPanel<T>
>> >
>> >- Tor Iver
>> >
>> >-----Original Message-----
>> >From: Chris Colman [mailto:chrisc@stepaheadsoftware.com]
>> >Sent: 11. april 2011 15:08
>> >To: users@wicket.apache.org
>> >Subject: Form composed of Panel components
>> >
>> >I have a complex form that I choose to break down into logical sub
>> Panel
>> >components and then add them as children to the Form.
>> >
>> >The sub Panels themselves then have FormComponents like text fields
and
>> >DropDownChoice components added to them. Will the normal
>> validate/update
>> >mechanism simply work like that or do I need to override some
methods
>> in
>> >my Panel classes or make the Panel classes implement certain
interfaces
>> >(eg., IFormVisitorParticipant etc.,)?
>> >
>> >Chris Colman
>> >
>> >
>>
>---------------------------------------------------------------------
>> >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
>>
>>
>
>
>--
>Pedro Henrique Oliveira dos Santos

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


Re: Form composed of Panel components

Posted by Pedro Santos <pe...@gmail.com>.
Form will process nested form components regardless of the web markup
container component you used to group them.

On Mon, Apr 11, 2011 at 10:46 AM, Chris Colman <chrisc@stepaheadsoftware.com
> wrote:

> I can't derive my Panels from FormComponentPanel because a strict
> inheritance hierarchy of Panels is already in place. I've started
> playing around with the Panels in question implementing
> IFormVisitorParticipant and IFormModelUpdateListener and this seems to
> be at least calling the validate and updateModel methods in my Panels
> now - I think plain vanilla Panels are ignored by the Form processing
> mechanism unless they implement these interfaces?
>
> >-----Original Message-----
> >From: Wilhelmsen Tor Iver [mailto:TorIverW@arrive.no]
> >Sent: Monday, 11 April 2011 11:11 PM
> >To: users@wicket.apache.org
> >Subject: RE: Form composed of Panel components
> >
> >Look into org.apache.wicket.markup.html.form.FormComponentPanel<T>
> >
> >- Tor Iver
> >
> >-----Original Message-----
> >From: Chris Colman [mailto:chrisc@stepaheadsoftware.com]
> >Sent: 11. april 2011 15:08
> >To: users@wicket.apache.org
> >Subject: Form composed of Panel components
> >
> >I have a complex form that I choose to break down into logical sub
> Panel
> >components and then add them as children to the Form.
> >
> >The sub Panels themselves then have FormComponents like text fields and
> >DropDownChoice components added to them. Will the normal
> validate/update
> >mechanism simply work like that or do I need to override some methods
> in
> >my Panel classes or make the Panel classes implement certain interfaces
> >(eg., IFormVisitorParticipant etc.,)?
> >
> >Chris Colman
> >
> >
> >---------------------------------------------------------------------
> >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
>
>


-- 
Pedro Henrique Oliveira dos Santos

RE: Form composed of Panel components

Posted by Chris Colman <ch...@stepaheadsoftware.com>.
I can't derive my Panels from FormComponentPanel because a strict
inheritance hierarchy of Panels is already in place. I've started
playing around with the Panels in question implementing
IFormVisitorParticipant and IFormModelUpdateListener and this seems to
be at least calling the validate and updateModel methods in my Panels
now - I think plain vanilla Panels are ignored by the Form processing
mechanism unless they implement these interfaces?

>-----Original Message-----
>From: Wilhelmsen Tor Iver [mailto:TorIverW@arrive.no]
>Sent: Monday, 11 April 2011 11:11 PM
>To: users@wicket.apache.org
>Subject: RE: Form composed of Panel components
>
>Look into org.apache.wicket.markup.html.form.FormComponentPanel<T>
>
>- Tor Iver
>
>-----Original Message-----
>From: Chris Colman [mailto:chrisc@stepaheadsoftware.com]
>Sent: 11. april 2011 15:08
>To: users@wicket.apache.org
>Subject: Form composed of Panel components
>
>I have a complex form that I choose to break down into logical sub
Panel
>components and then add them as children to the Form.
>
>The sub Panels themselves then have FormComponents like text fields and
>DropDownChoice components added to them. Will the normal
validate/update
>mechanism simply work like that or do I need to override some methods
in
>my Panel classes or make the Panel classes implement certain interfaces
>(eg., IFormVisitorParticipant etc.,)?
>
>Chris Colman
>
>
>---------------------------------------------------------------------
>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: Form composed of Panel components

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
Look into org.apache.wicket.markup.html.form.FormComponentPanel<T>

- Tor Iver

-----Original Message-----
From: Chris Colman [mailto:chrisc@stepaheadsoftware.com] 
Sent: 11. april 2011 15:08
To: users@wicket.apache.org
Subject: Form composed of Panel components

I have a complex form that I choose to break down into logical sub Panel
components and then add them as children to the Form.
 
The sub Panels themselves then have FormComponents like text fields and
DropDownChoice components added to them. Will the normal validate/update
mechanism simply work like that or do I need to override some methods in
my Panel classes or make the Panel classes implement certain interfaces
(eg., IFormVisitorParticipant etc.,)?
 
Chris Colman
 

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