cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From coli...@apache.org
Subject cvs commit: cocoon-2.1/src/scratchpad/webapp/samples/petstore/flow PetStoreImpl.js petstore.js
Date Mon, 17 Mar 2003 00:37:20 GMT
coliver     2003/03/16 16:37:20

  Modified:    src/scratchpad/webapp/samples/petstore sitemap.xmap
               src/scratchpad/webapp/samples/petstore/flow PetStoreImpl.js
                        petstore.js
  Log:
  adjusted for partial refactoring of system.js and some minor improvements
  
  Revision  Changes    Path
  1.2       +3 -1      cocoon-2.1/src/scratchpad/webapp/samples/petstore/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/webapp/samples/petstore/sitemap.xmap,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- sitemap.xmap	14 Mar 2003 17:15:09 -0000	1.1
  +++ sitemap.xmap	17 Mar 2003 00:37:19 -0000	1.2
  @@ -49,7 +49,9 @@
           <map:call continuation="{1}"/>
         </map:match>
         <map:match pattern="*.do">
  -        <map:call function="{1}"/>
  +        <map:call function="main">
  +          <map:parameter name="page" value="{1}"/>
  +        </map:call>
         </map:match>
         <map:match pattern="">
           <map:call function="index"/>
  
  
  
  1.2       +35 -35    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PetStoreImpl.js	14 Mar 2003 17:15:09 -0000	1.1
  +++ PetStoreImpl.js	17 Mar 2003 00:37:20 -0000	1.2
  @@ -44,6 +44,8 @@
   
   */
   
  +cocoon.load("resource://org/apache/cocoon/components/flow/Database.js");
  +
   function OrderForm() {
       this.order = new Order();
       this.shippingAddressRequired = false;        
  @@ -79,33 +81,33 @@
   }
   
   function Order() {
  -  this.orderId = 0;
  -  this.username= "";
  -  this.orderDate =null;
  -  this.shipAddress1= "";
  -  this.shipAddress2= "";
  -  this.shipCity= "";
  -  this.shipState= "";
  -  this.shipZip= "";
  -  this.shipCountry= "";
  -  this.billAddress1= "";
  -  this.billAddress2= "";
  -  this.billCity= "";
  -  this.billState= "";
  -  this.billZip= "";
  -  this.billCountry= "";
  -  this.courier= "";
  -  this.totalPrice= 0;
  -  this.billToFirstName= "";
  -  this.billToLastName= "";
  -  this.shipToFirstName= "";
  -  this.shipToLastName= "";
  -  this.creditCard= "";
  -  this.expiryDate= "";
  -  this.cardType= "";
  -  this.locale= "";
  -  this.status= "";
  -  this.lineItems = [];
  +    this.orderId = 0;
  +    this.username= "";
  +    this.orderDate =null;
  +    this.shipAddress1= "";
  +    this.shipAddress2= "";
  +    this.shipCity= "";
  +    this.shipState= "";
  +    this.shipZip= "";
  +    this.shipCountry= "";
  +    this.billAddress1= "";
  +    this.billAddress2= "";
  +    this.billCity= "";
  +    this.billState= "";
  +    this.billZip= "";
  +    this.billCountry= "";
  +    this.courier= "";
  +    this.totalPrice= 0;
  +    this.billToFirstName= "";
  +    this.billToLastName= "";
  +    this.shipToFirstName= "";
  +    this.shipToLastName= "";
  +    this.creditCard= "";
  +    this.expiryDate= "";
  +    this.cardType= "";
  +    this.locale= "";
  +    this.status= "";
  +    this.lineItems = [];
   }
   
   function Account() {
  @@ -135,12 +137,6 @@
       this.signOn = true;
   }
   
  -function Cart() {
  -    this.cartItems = {};
  -    this.numberOfItems = 0;
  -    this.subTotal = 0;
  -}
  -
   function CartItem(cart, item) {
       this.cart = cart;
       this.item = item;
  @@ -155,6 +151,12 @@
       this.quantity = newQuantity;
   }
   
  +function Cart() {
  +    this.cartItems = {};
  +    this.numberOfItems = 0;
  +    this.subTotal = 0;
  +}
  +
   Cart.prototype.addItem = function(item) {
       if (!(item.itemId in this.cartItems)) {
           this.cartItems[item.itemId] = new CartItem(this, item);
  @@ -379,7 +381,6 @@
       try {
           conn.update(CREATE_SCRIPT);
       } catch (ignored) {
  -        ignored.printStackTrace();
           conn.close();
           return;
       }
  @@ -489,7 +490,6 @@
   PetStore.prototype.getCategory = function(catId) {
       var conn = this.getConnection(this.poolId);
       var result = conn.query("select * from CATEGORY where CATID = '"+catId + "'");
  -    
       conn.close();
       return result.rows[0];
   }
  
  
  
  1.2       +25 -14    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- petstore.js	14 Mar 2003 17:15:09 -0000	1.1
  +++ petstore.js	17 Mar 2003 00:37:20 -0000	1.2
  @@ -65,9 +65,25 @@
   var cartForm = null;
   var categoryList = null;
   
  +
  +function main(funName) {
  +    var fun = this[funName];
  +    var args = new Array(arguments.length -1);
  +    for (var i = 1; i < arguments.length; i++) {
  +	args[i-1] = arguments[i];
  +    }
  +    getPetStore();
  +    fun.apply(args);
  +
  +}
  +
   function getPetStore() {
       if (petStore == null) {
  -        petStore = new PetStore("hsql");
  +        cocoon.createSession();
  +        this.petStore = new PetStore("hsql");
  +        this.cartForm = new CartForm();
  +        this.accountForm = new AccountForm();
  +	this.categoryList = getPetStore().getCategoryList();
       }
       return petStore;
   }
  @@ -75,12 +91,7 @@
   // Index page
   
   function index() {
  -    if (petStore == null) {
  -        cocoon.createSession();
  -        cartForm = new CartForm();
  -        accountForm = new AccountForm();
  -    }
  -    this.categoryList = getPetStore().getCategoryList();
  +    getPetStore();
       sendPage("view/templates/index.vm", {
                accountForm: accountForm,
                categoryList: categoryList
  @@ -118,7 +129,7 @@
       sendPage("view/templates/Cart.vm", {
                yoshi: yoshi, 
                accountForm: accountForm, 
  -            cartForm:cartForm
  +             cartForm:cartForm
       });
   }
   
  @@ -195,12 +206,12 @@
   function viewItem() {
       var itemId = cocoon.request.getParameter("itemId");
       var item = getPetStore().getItem(itemId);
  -    sendPageAndWait("view/templates/Item.vm", {
  -                    accountForm: accountForm, 
  -                    cartForm: cartForm, 
  -                    item: item, 
  -                    product: item.product, 
  -                    yoshi: yoshi
  +    sendPage("view/templates/Item.vm", {
  +             accountForm: accountForm, 
  +             cartForm: cartForm, 
  +             item: item, 
  +             product: item.product, 
  +             yoshi: yoshi
       });
   }
   
  
  
  

Mime
View raw message