home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / multi-page.js < prev    next >
Encoding:
JavaScript  |  2004-07-12  |  2.0 KB  |  60 lines

  1. /*
  2.  * Copyright 1999-2004 The Apache Software Foundation.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *      http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16.  
  17. // Multi-page Flow example
  18. // Simple multi-page form, without using Cocoon Forms
  19.  
  20. var date = new Packages.java.util.Date();
  21.  
  22. // simulated email message data
  23. function MessageData() {
  24.     this.sender = "you@somewhere.com";
  25.     this.subject = "Type the subject here";
  26.     this.text = "Type the text of your message here";
  27. }
  28.  
  29. // page flow
  30. function public_startMultiPage() {
  31.     var message = new MessageData();
  32.  
  33.     while(true) {
  34.  
  35.         // decide which page to show based on request parameters
  36.         page = "page1";
  37.         if(cocoon.request.getParameter("action_send") != null) {
  38.             break;
  39.         } else if(cocoon.request.getParameter("action_page2") != null) {
  40.             page = "page2";
  41.         }
  42.  
  43.         // show form and wait for results
  44.         cocoon.sendPageAndWait("multi-page/views/" + page, { "message" : message, "date" : date });
  45.  
  46.         // now for the boring part: copy form data into message
  47.         // that's where Forms bindings would help
  48.         tmp = cocoon.request.getParameter("sender");
  49.         if(tmp != null) message.sender = tmp;
  50.  
  51.         tmp = cocoon.request.getParameter("subject");
  52.         if(tmp != null) message.subject = tmp;
  53.  
  54.         tmp = cocoon.request.getParameter("text");
  55.         if(tmp != null) message.text = tmp;
  56.     }
  57.  
  58.     // user selected "send", show message contents
  59.     cocoon.sendPage("multi-page/views/result", { "message" : message });
  60. }