cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject multiple forms (was: Usage of "form.createBinding" compared with "form.load")
Date Mon, 13 Dec 2004 19:25:03 GMT
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


Mime
View raw message