cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew <andrewm...@gmail.com>
Subject Re: checkbox widget with datatype vector
Date Tue, 25 Jul 2006 15:52:10 GMT
Hi Jason,
we're nearly there! I've created the binding document, implemented it into
flow but no rows are being displayed when I update the order object!! What
am I overlooking?

flow:

var form = new Form("forms/artistOrder_new.xml");
form.createBinding("binding/artistOrder_binding.xml");
form.showForm("viewform-artistOrder_new.xml",{"artistID":artistID,"artist_name":artist_name,"artist_info":artist_info,"track_info":track_info,"track_location":track_location,"track_type":track_type,"stock_code":stock_code,"userGlobal":userGlobal,"neworder":neworder,"stock_price":stock_price,"msg":delItems,"msg2":msg2,
"track_title":track_title});
...........

        if (parseInt(bizData.quantity) || repeaterSize != 0) {
            try {

                if (repeaterSize != 0) { //Delete a row if need be
                    //delete a row and an item from the orderitem
                    for(var i=0; i < repeater.getSize(); i++) { //loop over
the rows
                      var row = repeater.getRow(i);

if(java.lang.Boolean.TRUE.equals(row.lookupWidget("delete").value))
{ //is the booleanfield checked?
                        itemsToDelete.add(row.lookupWidget("id").value);
//add the item id to delete from widget
                        deleteOrderItem2(itemsToDelete);

                        //now delete item row from repeater
                        form.load(neworder);
                      }
                    }

                }

                if (parseInt(bizData.quantity)) { //Add a row if need be
                    //add a row and an item to the orderitem
                    addOrderItem(bizData.quantity, bizData.orderID,
bizData.stockID);

                    //Now add this item to the repeater
                    form.load(neworder);

binding:

<?xml version="1.0"?>
<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"
            path="/">

<fb:simple-repeater id="items" parent-path="."
row-path="neworder/orderItems" direction="load">
  <fb:value id="id" path="ID" />
  <fb:value id="artistName" path="artistName" />
  <fb:value id="itemTitle" path="Stock/ItemTitle" />
  <fb:value id="amount" path="Amount />
  <fb:value id="price" path="Price" />
</fb:simple-repeater>

</fb:context>

jx file:

                              <ft:repeater-rows>
                              <tr>
                                <td width="8" class="normaltext"></td>
                                <td class="normaltext"><ft:widget id="id"
/></td>
                                <td width="8" class="normaltext"></td>
                                <td class="normaltext"><ft:widget
id="artistName" /></td>
                                <td width="8" class="normaltext"></td>
                                <td class="normaltext"><ft:widget
id="itemTitle" /></td>
                                <td class="normaltext"></td>
                                <td class="normaltext"><ft:widget
id="amount" /></td>
                                <td class="normaltext"></td>
                                <td class="normaltext"><ft:widget id="price"
/>.00</td>
                                <td class="normaltext"></td>
                                <td class="normaltext"><ft:widget
id="delete" /></td>
                              </tr>
                              </ft:repeater-rows>

fd:validation:

    <fd:repeater id="items" initial-size="0">
          <fd:widgets>
            <fd:output id="id">
                  <fd:datatype base="string" />
            </fd:output>
            <fd:output id="artistName">
                  <fd:datatype base="string" />
            </fd:output>
            <fd:output id="itemTitle">
                  <fd:datatype base="string" />
            </fd:output>
            <fd:output id="amount">
                  <fd:datatype base="string" />
            </fd:output>
            <fd:output id="price">
                  <fd:datatype base="string" />
            </fd:output>
            <fd:booleanfield id="delete" />
          </fd:widgets>
    </fd:repeater>

regards

Andrew





On 25/07/06, Jason Johnston <cocoon@lojjic.net> wrote:
>
> Andrew wrote:
> > Hi Jason,
> > first off I have to say I appreciate the time you put into helping me
> > grasp these concepts, much appreciated.
> >
>
> No problem.
>
> >
> > So how in flow do I add values to each of the widgets, (id, artistName,
> > etc etc etc), in the repeater, and then add that row to
> <ft:repeater-rows>?
>
> Like I mentioned before, I think the easiest way to load data into the
> repeater is with a fb:simple-repeater binding.  I presume you're not
> familiar with the binding framework; it's basically a way to define (in
> an XML syntax) how to map values between a business object and the form
> object's widgets.  See the documentation:
> http://cocoon.apache.org/2.1/userdocs/binding.html
>
> There's a special binding type called fb:simple-repeater (named such
> since it's much simpler than the full fb:repeater binding, but should be
> sufficient for your case) that lets you bind values from a Collection,
> Array, or anything else that JXPath can iterate over, to and from a
> fd:repeater widget and all its children.  Something like:
>
> In a binding file:
>
> ...
> <fb:simple-repeater id="items" parent-path="." row-path="orderItems"
>                      direction="load">
>    <fb:value id="id" path="ID" />
>    <fb:value id="artistName" path="..." />
>    ...
> </fb:simple-repeater>
> ...
>
> In your flow:
>
> form.createBinding("path/to/binding-file.xml"); //creates the binding
> ...
> form.load(neworder); //loads the data into the form using the binding
>
> That's it.  You can call form.load() as many times in your flow as you
> want, such as after you delete items or a new item is added.  As long as
> the orderItems list contains the up-to-date list of items, the repeater
> will be updated to match.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Mime
View raw message