You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Joerg Heinicke <jo...@gmx.de> on 2004/12/13 20:25:03 UTC

multiple forms (was: Usage of "form.createBinding" compared with "form.load")

On 13.12.2004 14:29, Philipp Rech wrote:

> hello,
> 
> thanks you Joerg that helped me a lot. And you are rigth about the default
> way, but i wasn't aware of the function Form.js in this case. Good
> to know where this file is, thanks!
> 
> my question remaning is how to bind several forms. do i have to call the
> handleForm function seperatly for each form or can i pass several bindingURI's
> 
> and from-definitions in one sitemap match area.

The default handles only one form on a page, not many forms. CForms is 
not even really multiple-forms-aware, but taking care about some things 
should make it possible.

1. handleForm() instantiates the form. If you need multiple forms, you 
also need multiple instances, what you have already done (in the private 
mail):

var form1 = new Form("cform-definitions/widgets_table_event.xml");
var form2 = new Form("cform-definitions/widgets_table_goods.xml");
var form3 = new Form("cform-definitions/widgets_table_person.xml");
var form4 = new 
Form("cform-definitions/widgets_table_means_of_transport.xml");

To complete the form instances you also need to create a binding for each:

form1.createBinding("binding1.xml");
form2.createBinding("binding2.xml");
...

If you need to load some values you also need to load them for all form 
instances:

form1.load(bean1);
form2.load(bean2); //or bean1 again
...

The same is true for the save later.

So the binding framework has absolutely no problems with multiple form 
instances. Displaying the form and handling a form submit is much more 
interesting. I don't know exactly how you can make it work, probably by 
passing the form instances to the FOM context:

cocoon.sendPageAndWait("confrim_event", {"form1": form1, "form2": form2, 
...});

Maybe someone has already tested it.

Joerg

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


[solved] multiple forms (was: Usage of "form.createBinding" compared with"form.load")

Posted by Philipp Rech <re...@iuw.fh-darmstadt.de>.
> The default handles only one form on a page, not many forms. CForms is 
> not even really multiple-forms-aware, but taking care about some things 
> should make it possible.
> 

thank you! it works now... i call handleForm and pass several bindings and form
definitions (from the sitemap) to it. In case you guys are interested here
is how i've done it:

In the flowscript i reverence them again (!) like:

var form1 = new Form("cform-definitions/form1.xml");
form1.createBinding("binding/binding1.xml"); 
var form2 = new Form("cform-definitions/form2.xml");
form2.createBinding("binding/binding2.xml"); 

it is important to call the function that is defined in the
sitmap without any parameters: function myBinding()
I decide which form to show via a switch/case statment using a 
variable from a request parameter....

works fine also with hibernate.... beautiful!
thanks Joerg,

phil

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