Author: mrdon Date: Sun Nov 27 21:48:21 2005 New Revision: 349383 URL: http://svn.apache.org/viewcvs?rev=349383&view=rev Log: Fixing wizard example
Modified: struts/flow/trunk/src/examples/WEB-INF/wizard/wizard-flow.js struts/flow/trunk/src/examples/WEB-INF/wizard/wizard.js struts/flow/trunk/src/java/org/apache/struts/flow/sugar/SugarWrapFactory.java Modified: struts/flow/trunk/src/examples/WEB-INF/wizard/wizard-flow.js URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/examples/WEB-INF/wizard/wizard-flow.js?rev=349383&r1=349382&r2=349383&view=diff ============================================================================== --- struts/flow/trunk/src/examples/WEB-INF/wizard/wizard-flow.js (original) +++ struts/flow/trunk/src/examples/WEB-INF/wizard/wizard-flow.js Sun Nov 27 21:48:21 2005 @@ -1,8 +1,7 @@ -importPackage(Packages.java.util); flow.load("/WEB-INF/wizard/wizard.js"); function main() { - var model = new HashMap(); + var model = new java.util.HashMap(); var wizard = new Wizard(model); wizard.populate = populate; @@ -20,9 +19,9 @@ } function populate() { - m = struts.paramValues; - for (i = m.keySet().iterator(); i.hasNext(); ) { - key = i.next(); + var m = struts.paramValues; + for (var i = m.keySet().iterator(); i.hasNext(); ) { + var key = i.next(); this.model.put(key, m.get(key)[0]); } // Bug in commons-chain prevents this Modified: struts/flow/trunk/src/examples/WEB-INF/wizard/wizard.js URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/examples/WEB-INF/wizard/wizard.js?rev=349383&r1=349382&r2=349383&view=diff ============================================================================== --- struts/flow/trunk/src/examples/WEB-INF/wizard/wizard.js (original) +++ struts/flow/trunk/src/examples/WEB-INF/wizard/wizard.js Sun Nov 27 21:48:21 2005 @@ -68,14 +68,9 @@ * @param lastWebCont The parent web continuation * @param bizdata A map of objects to pass to the form */ -Wizard.prototype.sendFormAndWait = function(name, lastWebCont, bizdata) { - var k = new Continuation(); - var wk = new WebContinuation(flow, k, lastWebCont, this.timeToLive); - flow.put(Packages.org.apache.struts.flow.Constants.FORWARD_NAME_KEY, name); - flow.put(Packages.org.apache.struts.flow.Constants.CONTINUATION_ID_KEY, wk.id); - flow.put(Packages.org.apache.struts.flow.Constants.BIZ_DATA_KEY, bizdata); - - suicide(); +Wizard.prototype.sendFormAndWait = function(name, lastWebCont, bizdata, ttl) { + flow.forward(name, bizdata, new FOM_WebContinuation(new Continuation(), lastWebCont, ttl)); + flow.exit(); } /** @@ -88,16 +83,16 @@ Wizard.prototype.showForm = function(frm, bizdata, doValidate, exitIds) { // Default validation to true if not passed - doValidate = (doValidate == null ? true : doValidate); + var doValidate = (doValidate == null ? true : doValidate); // Default to the next id if none passed - exitIds = (exitIds == null ? new Array(this.nextId) : exitIds); + var exitIds = (exitIds == null ? new Array(this.nextId) : exitIds); - var lastWebCont = lastContinuation; + var lastWebCont = flow.continuation; // create a continuation, the invocation of which will resend // the page: this is used to implement the back button - var wk = _startContinuation(lastWebCont); - log.debug("saving spot "+wk.id+" before form:"+frm); + var wk = new FOM_WebContinuation(new Continuation(), lastWebCont); + flow.log.debug("saving spot "+wk.id+" before form:"+frm); // Loop to keep showing form until validation passes and next button // is pressed @@ -123,7 +118,7 @@ // If validation is enabled, validate and determine if should keep // showing if (doValidate) { - errors = this.validate(frm); + var errors = this.validate(frm); if (errors == null || errors.length == 0) { bizdata[this.errorsKey] = null; } else { @@ -135,8 +130,8 @@ // Determine if next button is pressed and should stop showing if ((doValidate && !keepShowing) || !doValidate) { keepShowing = true; - params = struts.param; - for (id in exitIds) { + var params = struts.param; + for (var id in exitIds) { if (params[exitIds[id]] != null || params[exitIds[id]+'.x'] != null) { exitId = exitIds[id]; keepShowing = false; @@ -145,7 +140,7 @@ } } } - lastContinuation = thisWebCont; + flow.continuationn = thisWebCont; return exitId; } @@ -157,31 +152,29 @@ * * @param kont The continuation to restart */ -function handleContinuation(kont) { +function handleContinuation(k, wk) { // This can be overridden by declaring a "prevId" variable outside the function var prevId = (this.prevId != null ? this.prevId : "prev"); - log.debug("Previous Id:"+struts.param.get(prevId)); - if (struts.param.get(prevId) != null) { - log.debug("going back"); - k = kont.webContinuation; - for (x=0; x<3; x++) { - if (k == null) { - log.error("can't get parent continuation, back "+x); + flow.log.debug("Previous Id:"+struts.param[prevId]+" cont:"+wk.id); + if (struts.param[prevId]) { + var cont = wk; + for (var x=0; x<2; x++) { + if (cont == null) { + flow.log.error("can't get parent continuation, back "+x); break; } else { - k = k.parentContinuation; + cont = cont.getParent(); } } - if (k != null) { - log.debug("going back to "+k.id); - uo = k.getUserObject(); - uo.continuation(uo); + if (cont != null) { + cont.continuation(cont); } else { - kont.continuation(kont); + k(wk); } } else { - kont.continuation(kont); + k(wk); } } +flow.handleContinuation = handleContinuation; Modified: struts/flow/trunk/src/java/org/apache/struts/flow/sugar/SugarWrapFactory.java URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/java/org/apache/struts/flow/sugar/SugarWrapFactory.java?rev=349383&r1=349382&r2=349383&view=diff ============================================================================== --- struts/flow/trunk/src/java/org/apache/struts/flow/sugar/SugarWrapFactory.java (original) +++ struts/flow/trunk/src/java/org/apache/struts/flow/sugar/SugarWrapFactory.java Sun Nov 27 21:48:21 2005 @@ -83,7 +83,6 @@ Object javaObject, Class staticType) { Map map = getExtensionFunctions(javaObject.getClass()); - Scriptable wrap = null; if (javaObject instanceof Map) { wrap = new ScriptableMap(scope, javaObject, staticType, map); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]