Andrew wrote:
Hi,
I have a shopping cart system which enables a user to select a number of
items from their cart and delete them at the same time. This was working
perfectly before I chnaged everything to widgets because I need to use
ajax. What is happening now is that no matter how many items you select
to delete, only one item is ever deleted at a time. Now I suspect that
the problem lays with the datatype being used in fd:
<fd:field id="delItem" required="true|false">
<fd:datatype base="string"/> // I tried boolean and nothing was
being deleted
</fd:field>
widget definition is:
<ft:widget id= "delItem">
<fi:styling value="${orderitem.getID()}" type="checkbox"/>
</ft:widget>
I'm guessing that this is displayed multiple times using a JX forEach
loop, rather than a repeater?
I think just using an fd:multivaluefield should work; the widget will
take care of parsing the multiple values from the request into an Array
object. That would also simplify your flowscript since you'll always
get an Array rather than having to do the if/else for single vs.
multiple selection.
However, usually multivaluefield widgets have their individual checkbox
items generated from a selection-list, rather than by iterating manually
and calling ft:widget multiple times with different values. I'm not
sure how your approach will work with AJAX updates since it's a
nonstandard use of the widget.
flow:
delItems = bizData.delItem ;
var items = new java.util.Vector();
if (parseInt(bizData.quantity) || delItems != null) {
try {
if (delItems != null) {
if (delItems.iterator) { // A list of delItems have
been selected to be deleted.
items.addAll(delItems);
deleteOrderItem2(items);
} else { //A single delItem has been selected to be
deleted.
items.add(delItems);
deleteOrderItem2(items);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]