cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <>
Subject Re: [woody] Multiple bindings?
Date Sun, 15 Feb 2004 08:18:36 GMT
On Sat, 2004-02-14 at 19:57, Mark Lundquist wrote:
> A form can only be bound to one model, but I need a form that has
> theeffect of being bound to 2 beans (so in MVC terms the one form
> wouldcomprise 2 views, one of each model).
> Does anybody have any suggestions for how to achieve this?


First thing to know is that the binding is completely separate from the
form stuff, it's only the flowscript form object that integrates the two
to make them more convenient to use.

Basically you can get the idea again from looking what goes on in

Here's just some pseudocode of how to do it.

First declare a function like this:

function createBinding(bindingURI) {
    var bindingManager = null;
    var source = null;
    var resolver = null;
    try {
        bindingManager = cocoon.getComponent(;
        resolver = cocoon.getComponent(;
        source = resolver.resolveURI(bindingURI);
        return bindingManager.createBinding(source);
    } finally {
        if (source != null)

(this is mostly identical to the createBinding method in the form object)

then create the bindings like this:

var binding1 = createBinding("binding1.xml");
var binding2 = createBinding("binding2.xml");

and then for loading:

binding1.loadFormFromModel(form.form, bean1);
binding2.loadFormFromModel(form.form, bean2);

and for saving:

binding1.saveFormToModel(form.form, bean1);
binding2.saveFormToModel(form.form, bean2);

Thus when doing things this way, you don't need the form.load and methods.

Bruno Dumon                   
Outerthought - Open Source, Java & XML Competence Support Center                

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message