Hi,
I'm having problems binding my JavaBean hierarchy
to a CFORM. I am setting a default city in my Address bean and it is
not being mapped into the form once the form is loaded.
I have an Order bean which holds a
collection (ArrayList) of Delivery beans. Each
Delivery bean holds an Address bean. I am just trying to set
up one Delivery bean to map into the form (i.e. I'm not adding rows,
I'm just trying to get the first address to work).
I would really appreciate any help on this.
Basically my binding is exactly the same as the contact details example that
ships with Cocoon
(<cocoon-home>\src\blocks\forms\samples\forms\form2_bind_xml)
except I am going down to a deeper path (i.e. delivery/address). My binding is set up in the flowscript:
function getOrderDeliveryForm()
{
var form = new Form("forms/orderDelivery.xml"); form.createBinding("forms/orderDelivery-binding.xml"); return form; } Here is the other pertinent code and
xml:
Flowscript
var form = getOrderDeliveryForm();
var order = new Packages.net.au.whirlwind.data.Order(); var delivery = new Packages.net.au.whirlwind.data.Delivery(); var address = new Packages.net.au.whirlwind.data.Address(); address.setCity("Melbourne");
delivery.setId(1); delivery.setAddress(address); order.addDelivery(delivery); form.load(order);
form.showForm( "form-orderDelivery",
{"view": param} );
form.save(order); orderDelivery.xml
<?xml version="1.0"?>
<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" xmlns:i18n="http://apache.org/cocoon/i18n/2.1"> <fd:widgets> <fd:repeater id="deliveries" initial-size="1"> <fd:label>Delivery</fd:label> <fd:hint>this is a hint</fd:hint> <fd:help>this is some help</fd:help> <fd:widgets> <fd:output id="id"> <fd:datatype base="long"/> </fd:output> <fd:field id="street" required="false"> <fd:label>Street</fd:label> <fd:datatype base="string"/> </fd:field> <fd:field id="suburb" required="false"> <fd:label>Suburb</fd:label> <fd:datatype base="string"/> </fd:field> <fd:field id="city" required="false"> <fd:label>City</fd:label> <fd:datatype base="string"/> </fd:field> <fd:field id="state" required="false"> <fd:label>State</fd:label> <fd:datatype base="string"/> </fd:field> <fd:field id="postcode" required="false"> <fd:label>Postcode</fd:label> <fd:datatype base="string"> <fd:converter type="plain"/> </fd:datatype> <fd:on-value-changed> <_javascript_> optionswidget = event.source.lookupWidget("../options"); optionswidget.setSelectionList( h.calcDeliveryOption(), "id", "name" ); </_javascript_> </fd:on-value-changed> </fd:field> <fd:field id="country" required="false"> <fd:label>Country</fd:label> <fd:datatype base="string"/> </fd:field> <fd:field id="options" required="false"> <fd:label>Options:</fd:label> <fd:datatype base="string"/> <fd:selection-list> <fd:item value=""> <fd:label>Select a postcode first</fd:label> </fd:item> </fd:selection-list> </fd:field> <fd:row-action id="delivery-remove" action-command="delete"> <fd:label>remove</fd:label> <fd:help>help</fd:help> <fd:hint>hint</fd:hint> </fd:row-action> </fd:widgets> </fd:repeater> <fd:repeater-action id="delivery-add" action-command="add-row" repeater="delivery"> <fd:label>add address</fd:label> <fd:help>help</fd:help> <fd:hint>hint</fd:hint> </fd:repeater-action> </fd:widgets> </fd:form> orderDelivery-binding.xml
<?xml
version="1.0"?>
<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" path="/"> <fb:repeater id="deliveries" parent-path="deliveries" row-path="delivery"> <fb:identity> <fb:value id="id" path="@id"/> </fb:identity> <fb:on-bind> <fb:value id="street" path="address/street"/> <fb:value id="suburb" path="address/suburb"/> <fb:value id="city" path="address/city"/> <fb:value id="state" path="address/state"/> <fb:value id="postcode" path="address/postCode"/> <fb:value id="country" path="address/country"/> <fb:value id="options" path="method"/> </fb:on-bind> </fb:repeater> </fb:context> I have also tried setting the parent-path to ".",
again to no avail.
What am I doing wrong? Basically I don't get any
errors, but "Melbourne" simply does not appear in the city field.
Thanks in advance.
Regards,
Neil Killick ------ Public Image Creative Strategy & Production for Print, Online & Broadcast Media Public Image Software
The SONAR™ family of Management Information Systems for the creative industries Melbourne Studios:
Telephone +61 3 9650 0650 Facsimile +61 3 9650 0770 |
- Re: Problem with repeater binding in CForm Neil Killick
- Re: Problem with repeater binding in CForm Marc Portier
- Re: Problem with repeater binding in CForm Neil Killick
- Re: Problem with repeater binding in CForm Neil Killick
- Re: Problem with repeater binding in CForm Marc Portier
- Re: Problem with repeater binding in CForm Neil Killick
- Re: Problem with repeater binding in CF... Marc Portier