You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by co...@apache.org on 2003/04/01 21:25:11 UTC
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript xmlForm.js
coliver 2003/04/01 11:25:11
Modified: src/java/org/apache/cocoon/components/flow/javascript
xmlForm.js
Log:
Removed dependency on session. Request scope should now work. Call back to JavaScriptInterpreter.handleContinuation to ensure that cocoon object is set up properly when invoking continuation. Added workaround while I look into apparent dynamic scoping bug in Rhino that causes session scope forms to fail with multiple users
Revision Changes Path
1.8 +32 -51 cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/xmlForm.js
Index: xmlForm.js
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/xmlForm.js,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- xmlForm.js 29 Mar 2003 19:12:24 -0000 1.7
+++ xmlForm.js 1 Apr 2003 19:25:11 -0000 1.8
@@ -15,21 +15,17 @@
*/
function XForm(id, validatorNS, validatorDoc, scope) {
- if (scope != "request") {
+ if (scope == "session") {
cocoon.createSession();
}
+ this.cocoon = cocoon; // workaround for Rhino dynamic scope bug
this.id = id;
this.lastContinuation = null;
- XForm.forms[id] = this;
this.validatorNS = validatorNS;
this.validatorDoc = validatorDoc;
this.dead = false;
}
-/**
- * Global variable that stores XForm instances by id
- */
-XForm.forms = {};
/**
* Return the model object of this form
@@ -63,7 +59,7 @@
*/
XForm.prototype.start = function(lastCont, timeToLive) {
var k = new Continuation();
- var kont = new WebContinuation(cocoon, k,
+ var kont = new WebContinuation(this.cocoon, k,
lastCont, timeToLive);
return kont;
}
@@ -119,17 +115,17 @@
}
XForm.prototype._sendView = function(uri, lastCont, timeToLive) {
- var k = new Continuation();
- var kont = new WebContinuation(cocoon, k, lastCont, timeToLive);
- var bizData = this.form.getModel();
- if (bizData == undefined) {
- bizData = null;
- }
-
- cocoon.forwardTo("cocoon://" + cocoon.environment.getURIPrefix() + uri,
- bizData, kont);
- this.lastContinuation = kont;
- suicide();
+ var k = new Continuation();
+ var kont = new WebContinuation(this.cocoon, k, lastCont, timeToLive);
+ var bizData = this.form.getModel();
+ if (bizData == undefined) {
+ bizData = null;
+ }
+ this.cocoon.forwardTo("cocoon://" +
+ this.cocoon.environment.getURIPrefix() + uri,
+ bizData, kont);
+ this.lastContinuation = kont;
+ suicide();
}
/**
@@ -147,31 +143,31 @@
XForm.prototype.sendView = function(phase, uri, validator) {
var lastCont = this.lastContinuation;
this.form.clearViolations();
- var view = this.form.getFormView(cocoon.environment.objectModel);
+ var view = this.form.getFormView(this.cocoon.environment.objectModel);
while (true) {
// create a continuation, the invocation of which will resend
// the page: this is used to implement <xf:submit continuation="back">
var k = this.start(lastCont);
- if (cocoon.request == null) {
+ if (this.cocoon.request == null) {
// this continuation has been invalidated
this.dead = true;
handleInvalidContinuation();
suicide();
}
// reset the view in case this is a re-invocation of a continuation
- cocoon.request.setAttribute("view", view);
- this.form.remove(cocoon.environment.objectModel, this.id);
- this.form.save(cocoon.environment.objectModel, "request");
+ this.cocoon.request.setAttribute("view", view);
+ this.form.remove(this.cocoon.environment.objectModel, this.id);
+ this.form.save(this.cocoon.environment.objectModel, "request");
this._sendView(uri, k);
// _sendView creates a continuation, the invocation of which
// will return right here: it is used to implement
// <xf:submit continuation="forward">
- if (this.dead || cocoon.request == null) {
+ if (this.dead || this.cocoon.request == null) {
// this continuation has been invalidated
handleInvalidContinuation();
suicide();
}
- this.form.populate(cocoon.environment.objectModel);
+ this.form.populate( this.cocoon.environment.objectModel);
if (validator != undefined) {
validator(this);
}
@@ -186,7 +182,7 @@
// if validator params are not specified, then
// there is no validation by default
if (schNS == null || schDoc == null ) return null;
- var resolver = cocoon.environment;
+ var resolver = this.cocoon.environment;
var schemaSrc = resolver.resolveURI( schDoc );
try {
var is = Packages.org.apache.cocoon.components.source.SourceUtil.getInputSource(schemaSrc);
@@ -204,20 +200,12 @@
*/
XForm.prototype.finish = function(uri) {
- try {
- this.form.save(cocoon.environment.objectModel, "request");
- } catch (e if (e instanceof java.lang.IllegalStateException)) {
- if (cocoon.session.getAttribute(this.id) != null) {
- // someone else has taken my session
- this.dead = true;
- handleInvalidContinuation();
- suicide();
- }
- throw e;
- }
- cocoon.forwardTo("cocoon://" + cocoon.environment.getURIPrefix() + uri,
- this.form.getModel(), null);
- delete XForm.forms[this.id]; // delete myself
+ this.form.remove( this.cocoon.environment.objectModel, this.id);
+ this.form.save( this.cocoon.environment.objectModel, "request");
+ this.cocoon.forwardTo("cocoon://" +
+ this.cocoon.environment.getURIPrefix() + uri,
+ this.form.getModel(),
+ null);
this.dead = true;
if (this.lastContinuation != null) {
this.lastContinuation.invalidate();
@@ -259,16 +247,9 @@
var command = getCommand();
if (command != undefined) {
// invoke a continuation
- var continuationsMgr =
- cocoon.componentManager.lookup(Packages.org.apache.cocoon.components.flow.ContinuationsManager.ROLE);
- var wk = continuationsMgr.lookupWebContinuation(command);
- cocoon.componentManager.release(continuationsMgr);
- if (wk != null) {
- var jswk = wk.userObject;
- jswk.continuation(jswk);
- // note: not reached
- }
- handleInvalidContinuation(command);
+ cocoon.interpreter.handleContinuation(command,
+ null,
+ cocoon.environment);
return;
}
if (id != null) {