Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 94547 invoked by uid 500); 24 Feb 2003 04:00:47 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 94534 invoked from network); 24 Feb 2003 04:00:47 -0000 Received: from out003pub.verizon.net (HELO out003.verizon.net) (206.46.170.103) by daedalus.apache.org with SMTP; 24 Feb 2003 04:00:47 -0000 Received: from verizon.net ([4.46.80.164]) by out003.verizon.net (InterMail vM.5.01.05.20 201-253-122-126-120-20021101) with ESMTP id <20030224040056.PBUX3094.out003.verizon.net@verizon.net> for ; Sun, 23 Feb 2003 22:00:56 -0600 Message-ID: <3E5998EE.9000603@verizon.net> Date: Sun, 23 Feb 2003 20:00:46 -0800 From: Christopher Oliver Reply-To: coliver@apache.org User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cocoon-dev@xml.apache.org Subject: Re: XMLForm/Flow Integration References: <3E52BFF4.2030902@verizon.net> <040501c2dbb2$6c8a9bc0$0100a8c0@MAUCHI> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Authentication-Info: Submitted using SMTP AUTH at out003.verizon.net from [4.46.80.164] at Sun, 23 Feb 2003 22:00:56 -0600 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ivelin wrote: > Chris, > > I am trying to get my hands around your code. > I see the function which loops until there are no more input violations and > although I have a guess about the response, I would still like to hear from > you on these questions: > > Where would you place calls to the backend which for example pull data from > a database to populate the bean for the next page? > Where would if place logic which decides what is the next page based on > input choices made on the current page? > > > -=Ivelin=- > > Below is a variation of the feedback wizard example that should answer your questions. Where you see print("handling xxxxx") that is where you would perform back-end actions like reading from a database, as well as where you would decide which page to send next based on the values set in the bean by the previous page. The contrived example below shows the deployment and system pages in reverse order if the "age" you enter in the userIdentity page is greater than 20. Regards, Chris // XML Form Feedback Wizard Application function deployment(xform) { xform.sendView("deployment", "flow/deployment.xml", function(xform) { var bean = xform.getModel(); print("I can also do validation in JavaScript"); if (bean.publish) { xform.addViolation("/publish", "Sorry, I won't let you publish"); } }); print("handling deployment"); } function system(xform) { xform.sendView("system", "flow/system.xml"); print("handling system"); } function feedbackWizard(xform) { var bean = { firstName: "Donald", lastName: "Duck", email: "donald_duck@disneyland.com", age: 5, number: 1, liveUrl: "http://", publish: true, hidden: true, count: 1, notes: "", favorite: ["http://xml.apache/org/cocoon", "http://jakarta.apache.org", "http://www.google.com", "http://www.slashdot.com", "http://www.yahoo.com"], hobby: ["swim", "movies", "ski", "gym", "soccer"], allHobbies: [ { key: "swim", value: "Swimming" }, { key: "gym", value: "Body Building" }, { key: "ski", value: "Skiing" }, { key: "run", value: "Running" }, { key: "football", value: "Football" }, { key: "read", value: "Reading" }, { key: "write", value: "Writing" }, { key: "soccer:", value: "Soccer" }, { key: "blog", value: "Blogging" }], role: ["Hacker", "Executive"], system: { os: "Unix", processor: "p4", ram: 512, servletEngine: "Tomcat", javaVersion: "1.3", } } xform.setModel(bean); xform.sendView("userIdentity", "flow/userIdentity.xml", function(xform) { var bean = xform.getModel(); print("I can also do validation in JavaScript"); print("age = "+xform.xpath("number(/age)")); print("role = "+bean.role); if (bean.age > 40) { xform.addViolation("/age", "Hey, you're too old"); } }); print("handling user identity"); if (bean.age > 20) { system(xform); deployment(xform); } else { deployment(xform); system(xform); } xform.sendView("confirm", "flow/confirm.xml"); print("handling confirm"); xform.finish("end", "flow/end.xml"); print("done"); }