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 petstore.js
Date Wed, 30 Apr 2003 20:09:45 GMT
coliver     2003/04/30 13:09:45

  Modified:    src/scratchpad/src/org/apache/cocoon/generation
                        JXFormsGenerator.java
               src/scratchpad/webapp/samples/petstore/flow petstore.js
  Log:
  fixed JXForm handling
  
  Revision  Changes    Path
  1.7       +0 -1      cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JXFormsGenerator.java
  
  Index: JXFormsGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JXFormsGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JXFormsGenerator.java	30 Apr 2003 18:37:12 -0000	1.6
  +++ JXFormsGenerator.java	30 Apr 2003 20:09:44 -0000	1.7
  @@ -496,7 +496,6 @@
               this.startElement = startElement;
           }
           final XPathExpr ref;
  -        boolean absolute;
           final StartElement startElement;
           EndInputControl endInputControl;
       }
  
  
  
  1.13      +20 -13    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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- petstore.js	30 Apr 2003 09:39:01 -0000	1.12
  +++ petstore.js	30 Apr 2003 20:09:44 -0000	1.13
  @@ -341,7 +341,7 @@
   }
   
   //
  -// Edit Account page: example of using XMLForm in a flow script
  +// Edit Account page: example of using JXForms in a flow script
   //
   
   
  @@ -368,6 +368,13 @@
       return reg.test(value);
   }
   
  +function empty(str) {
  +    return str == null || 
  +      (str instanceof java.lang.String ?  
  +           str.length() == 0 :
  +                  str.length == 0);
  +}
  +
   function editAccountForm(form) {
       var model = {accountForm: accountForm,
                    account: accountForm.account,
  @@ -378,22 +385,22 @@
       form.setModel(model);
       form.sendView("view/jxforms/EditUserInformation.xml", 
                     function(form) {
  -        if (model.userName == "") {
  +        if (empty(model.username)) {
               form.addViolation("/userName", "User ID is required");
           } else {
  -	    if (model.password == null || model.password.length == 0) {
  -		form.addViolation("/password", "Password is required");
  -	    } else if (model.password != model.password2) {
  -                form.addViolation("/password2", "Passwords don't match");
  -            }
  +          if (empty(model.password)) {
  +                form.addViolation("/password", "Password is required");
  +          } else if (model.password != model.password2) {
  +            form.addViolation("/password2", "Passwords don't match");
  +          }
           }
       });
       form.sendView("view/jxforms/EditAccountInformation.xml", 
                     function(form) {
  -        if (account.firstName == "") {
  +        if (empty(account.firstName)) {
               form.addViolation("/account/firstName", "First name is required");
           }
  -        if (account.lastName == "") {
  +        if (empty(account.lastName)) {
               form.addViolation("/account/lastName", "Last name is required");
           }
           if (!validateEmail(account.email)) {
  @@ -415,7 +422,7 @@
   
   function searchProducts() {
       var keyword = cocoon.request.get("keyword");
  -    if (keyword == null || keyword == "") {
  +    if (empty(keyword)) {
           sendPage("/view/Error" + EXT, {
              view: VIEW,
              message: "Please enter a keyword to search for, then press the search button"
  @@ -471,7 +478,7 @@
       var valid = false;
       while (!valid) {
           sendPageAndWait("/view/NewOrderForm" + EXT, { 
  -	                accountForm: accountForm,
  +                        accountForm: accountForm,
                           view: VIEW,
                           fmt: fmt,
                           creditCardTypes: ["Visa", "MasterCard", "American Express"],
  @@ -485,14 +492,14 @@
           valid = true;
       }
       sendPageAndWait("/view/ConfirmOrder" + EXT,
  -	            {accountForm: accountForm,
  +                    {accountForm: accountForm,
                        view: VIEW, order: order, fmt: fmt});
       
       var oldCartForm = cartForm;
       cartForm = new CartForm();
       sendPage("/view/ViewOrder" + EXT,
                {view: VIEW, order: order, 
  -	      accountForm: accountForm,
  +              accountForm: accountForm,
                 itemList: order.lineItems, 
                 fmt: fmt});
   }
  
  
  

Mime
View raw message