coliver 2003/03/16 20:51:53
Modified: src/scratchpad/webapp/samples/petstore/flow PetStoreImpl.js
petstore.js
src/scratchpad/webapp/samples/petstore/view/templates
Item.vm ViewOrder.vm
Log:
changes to fix quantity in Item page
Revision Changes Path
1.4 +9 -1
cocoon-2.1/src/scratchpad/webapp/samples/petstore/flow/PetStoreImpl.js
Index: PetStoreImpl.js
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/scratchpad/webapp/samples/petstore/flow/PetStoreImpl.js,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PetStoreImpl.js 17 Mar 2003 01:16:19 -0000 1.3
+++ PetStoreImpl.js 17 Mar 2003 04:51:52 -0000 1.4
@@ -549,7 +549,15 @@
var rs = conn.query("select count(*) as ROWCOUNT from PRODUCT where CATEGORY =
'" + key + "'");
var result = rs.rows[0].ROWCOUNT;
conn.close();
- return result;
+ return Number(result);
+}
+
+PetStore.prototype.getItemRowCountByProduct = function(key) {
+ var conn = this.getConnection(this.poolId);
+ var rs = conn.query("select count(*) as ROWCOUNT from ITEM where PRODUCTID = '"
+ key + "'");
+ var result = rs.rows[0].ROWCOUNT;
+ conn.close();
+ return Number(result);
}
PetStore.prototype.searchProductList = function(key, skipResults, maxResults) {
1.3 +3 -2
cocoon-2.1/src/scratchpad/webapp/samples/petstore/flow/petstore.js
Index: petstore.js
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/scratchpad/webapp/samples/petstore/flow/petstore.js,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- petstore.js 17 Mar 2003 00:37:20 -0000 1.2
+++ petstore.js 17 Mar 2003 04:51:52 -0000 1.3
@@ -70,7 +70,7 @@
var fun = this[funName];
var args = new Array(arguments.length -1);
for (var i = 1; i < arguments.length; i++) {
- args[i-1] = arguments[i];
+ args[i-1] = arguments[i];
}
getPetStore();
fun.apply(args);
@@ -83,7 +83,7 @@
this.petStore = new PetStore("hsql");
this.cartForm = new CartForm();
this.accountForm = new AccountForm();
- this.categoryList = getPetStore().getCategoryList();
+ this.categoryList = getPetStore().getCategoryList();
}
return petStore;
}
@@ -210,6 +210,7 @@
accountForm: accountForm,
cartForm: cartForm,
item: item,
+ quantity: getPetStore().getItemRowCountByProduct(item.productId),
product: item.product,
yoshi: yoshi
});
1.2 +3 -4
cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/templates/Item.vm
Index: Item.vm
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/templates/Item.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Item.vm 14 Mar 2003 17:15:27 -0000 1.1
+++ Item.vm 17 Mar 2003 04:51:53 -0000 1.2
@@ -34,11 +34,10 @@
<font size="3"><i>$product.name</i></font>
</td></tr>
<tr bgcolor="#FFFF88"><td>
-#if ($item.quantity.intValue() <= 0)
+#if ($quantity.intValue() <= 0)
<font color="RED" size="2"><i>Back ordered.</i></font>
-#end
-#if ($item.quantity.intValue() >= 1)
- <font size="2">$item.quantity in stock.</font>
+#else
+ <font size="2">$quantity.intValue() in stock.</font>
#end
</td></tr>
<tr bgcolor="#FFFF88"><td>
1.2 +5 -5
cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/templates/ViewOrder.vm
Index: ViewOrder.vm
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/templates/ViewOrder.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ViewOrder.vm 14 Mar 2003 17:15:27 -0000 1.1
+++ ViewOrder.vm 17 Mar 2003 04:51:53 -0000 1.2
@@ -109,24 +109,24 @@
<tr bgcolor="#FFFF88">
<td><b><a href="viewItem.do?itemId=$cartItem.item.itemId"><font
color="BLACK">$cartItem.item.itemId</font></a></b></td>
<td>
-#if ($cartItem.item)
+ #if ($cartItem.item)
$!cartItem.item.attr1
$!cartItem.item.attr2
$!cartItem.item.attr3
$!cartItem.item.attr4
$!cartItem.item.attr5
$!cartItem.item.product.name
-#else
+ #else
<i>{description unavailable}</i>
-#end
+ #end
</td>
- <td>$cartItem.quantity</td>
+ <td>$cartItem.quantity.intValue()</td>
<td align="right">$cartItem.item.listPrice</td>
</tr>
#end
<tr bgcolor="#FFFF88">
- <td colspan="4" align="right"><b>Total: $order.totalPrice</b></td>
+ <td colspan="4" align="right"><b>Total: $yoshi.formatNumber($order.totalPrice,
'$#,##0.00'</b></td>
</tr>
</table>
</td></tr>