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 06:55:47 GMT
Hi Jason,
first off I have to say I appreciate the time you put into helping me grasp
these concepts, much appreciated.

Ok, so I have in 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>

and in my 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>

and in my flow:

                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

                        //now delete item from orderitems object
                        items.add(row.lookupWidget("id").value);
                        deleteOrderItem2(items);
                      }
                    }

                }

                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);

                   // add values to repeater widgets, and then add row to
repeater-rows
                }

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>?

regards

Andrew

On 25/07/06, Jason Johnston <cocoon@lojjic.net> wrote:
>
> Jason Johnston wrote:
> > var itemsToDelete = new java.util.Vector();
> > var repeater = form.lookupWidget("items");
> > for(var i=0; i<repeater.getSize(); i++) { //loop over the rows
> >   var row = repeater.getRow(i);
> >   if(row.lookupWidget("delete").value) { //is the booleanfield checked?
>
> Small correction... the above line should probably be something more like:
>
> if(java.lang.Boolean.TRUE.equals(row.lookupWidget("delete").value)) {
>
> Datatype conversion between Java and JS can be tricky at times. ;-)
>
>
> >     itemsToDelete.add(row.lookupWidget("id").value); //add the item id
> >   }
> > }
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Mime
View raw message