You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Stefan Klein <st...@gmx.de> on 2009/05/10 02:26:36 UTC

FormTable and CayenneForm (was: Re: FormTable and Submit)

-------- Original-Nachricht --------
> Datum: Thu, 23 Apr 2009 12:12:39 +0200
> Von: Bob Schellink <sa...@gmail.com>
> An: click-user@incubator.apache.org
> Betreff: Re: FormTable and Submit

> With FormTable your options are more limited because the FormTable 
> rows must be filled *before* onProcess occurs, otherwise the Field and 
> Button values won't be processed and their actions won't be invoked.

I wanted to use a FormTable with an CayenneForm, using getDataObject().get/toManyRelationShip/() to set the rowlist of the FormTable.
getDataObject() tries to construct the dataobject by using the oidField which holds the primary key. Well, the oidField only holds the primary key after it is proccessed. So to get the column fields of the FormTable get processed it needs to have it's rows filled befor onProcess, but i only get the row list after onProcess (if i am using the suplied getter).

Should i read the value of FO_ID on my own, construct the dataobject and use setDataObject to set it or is there a cleaner/better way to solve this?

Stefan
-- 
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!* http://dslspecial.gmx.de/freedsl-surfflat/?ac=OM.AD.PD003K11308T4569a

Re: FormTable and CayenneForm

Posted by Stefan Klein <st...@gmx.de>.
Hi Bob,

> > Should i read the value of FO_ID on my own, construct the dataobject and
> use setDataObject to set it or is there a cleaner/better way to solve
> this?
> 
> 
> You are right, you need to ensure the oidField contains its value 
> *before* onProcess in order to populate the FormTable.
> 
> You could encapsulate this "early binding" with a custom CayenneForm 
> so that the oidField and classField values are available before 
> onProcess. For example:
> 
>    public class MyCayenneForm extends CayenneForm {
> 
>      public MyCayenneForm(String name) {
>        super(name);
> 
>        // Bind the oidField and classField to request parameters
>        oidField.bindRequestValue();
>        classField.bindRequestValue();
>      }
>    }
> 
> Hope this helps.

thank you, it works with a little change, I must not bind the requestvalue of the classField. If I do so, setting the DataObject on an get request fails since the value of cause is null and setDataObject checks if the given object is of the right class.

kind regards,
Stefan
-- 
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!* http://dslspecial.gmx.de/freedsl-surfflat/?ac=OM.AD.PD003K11308T4569a

Re: FormTable and CayenneForm

Posted by Bob Schellink <sa...@gmail.com>.
Hi Stefan,

Stefan Klein wrote:
> 
> I wanted to use a FormTable with an CayenneForm, using getDataObject().get/toManyRelationShip/() to set the rowlist of the FormTable.
> getDataObject() tries to construct the dataobject by using the oidField which holds the primary key. Well, the oidField only holds the primary key after it is proccessed. So to get the column fields of the FormTable get processed it needs to have it's rows filled befor onProcess, but i only get the row list after onProcess (if i am using the suplied getter).
> 
> Should i read the value of FO_ID on my own, construct the dataobject and use setDataObject to set it or is there a cleaner/better way to solve this?


You are right, you need to ensure the oidField contains its value 
*before* onProcess in order to populate the FormTable.

You could encapsulate this "early binding" with a custom CayenneForm 
so that the oidField and classField values are available before 
onProcess. For example:

   public class MyCayenneForm extends CayenneForm {

     public MyCayenneForm(String name) {
       super(name);

       // Bind the oidField and classField to request parameters
       oidField.bindRequestValue();
       classField.bindRequestValue();
     }
   }

Hope this helps.

kind regards

bob