Marcin Okraszewski wrote:

Hi Christian,
What about making an aggregating bean that would have two fields "Address" and "City"? You could make paths like this "address/street", "city/name".



good idea, and probably the best thing you could do for this example of address/city:
AFAICS there is some natural argumentation to see these two as part of a bigger thing, or reversely put: it doesn't seem to do enormous injustice to these objects to put them together, and to threat their binding together?


for this 'joining' of beans you don't even need to create a separate JavaBean to wrap them, a simple js-object with properties will do that

var joinedBean = new Object();
joinedBean.address = addressBean;
joinedBean.city = cityBean;

form.createBinding(uriToOneSingleBinding);
form.load(joinedBean);
form.show("some-pipeline");
form.save(joinedBean);



However, in the more general case there is nothing that prevents you to have two binding descriptions that can be used on the same form, and that bind only part of the widgets to different beans.

if you are used to the javascript API to woody/cforms then this might come as a surprise: it tailors best for the most common case of 1 form - 1 binding - 1 backend bean by adding a form.binding property that holds the 'one' you should be using...

however, if you look into the internals of Forms.js (or woody2.js depending on the schedule of you switching over) you will see how things actually are being processed (and find it is no big deal)

In any case, you don't need to duplicate all that nice stuff in your own processing for this simple case, you can simply add some properties to the object, or if you don't trust that keep those references in your own separate little js-object like this:

  //create and set form.binding to the binding under the argument-uri
form.createBinding(uriToBindingForAddress);
  //hold onto that reference
form.addressBinding = form.binding;

  //create and set form.binding to the binding under the argument-uri
form.createBinding(uriToBindingForCity);
  //hold onto that reference
form.cityBinding = form.binding;

and now, before using load(address) or save(address) you should reset

form.binding = form.addressBinding

and the same trick for the city


as you see, this is more work that would only be justified by reasons of higher separation of the two bindings (different lifecycle, backend, ...)


HTH,
-marc=



Regards,
Marcin Okraszewski


Hi!

I'd like to use Woody as a Database Frontend with OJB as persistance layer.
Is it possible to bind a form to two beans?
Example:
________________ _______________
| Address | | City |
|----------------| |---------------|
| +postcode | | +postcode |
| +street | | +name |
------------------ -----------------


How can i bind a form for editing a new address to this two beans? Any ideas?

Thanks in advance!
  Christian Plate


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- Marc Portier http://outerthought.org/ Outerthought - Open Source, Java & XML Competence Support Center Read my weblog at http://blogs.cocoondev.org/mpo/ [EMAIL PROTECTED] [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to