r9758 - in helma-ng/trunk: apps/demo modules/helma/webapp
[email protected] Thu, 14 May 2009 17:27:32 +0200 (CEST)
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <20090514152732.63D793D0D6@mia> |
Author: hannes
Date: 2009-05-14 17:27:32 +0200 (Thu, 14 May 2009)
New Revision: 9758
Modified:
helma-ng/trunk/apps/demo/actions.js
helma-ng/trunk/modules/helma/webapp/continuation.js
Log:
Switch continuation support from query params to extra path arguments, making it a lot more elegant.
Details at http://dev.helma.org/trac/helma/changeset/9758
Modified: helma-ng/trunk/apps/demo/actions.js
===================================================================
--- helma-ng/trunk/apps/demo/actions.js 2009-05-14 15:27:28 UTC (rev 9757)
+++ helma-ng/trunk/apps/demo/actions.js 2009-05-14 15:27:32 UTC (rev 9758)
@@ -49,9 +49,9 @@
}
// demo for continuation support
-function continuation(req) {
+function continuation(req, cont_id, cont_step) {
- var session = new ContinuationSession(req);
+ var session = new ContinuationSession(req, cont_id, cont_step);
if (!session.isActive()) {
// render welcome page
Modified: helma-ng/trunk/modules/helma/webapp/continuation.js
===================================================================
--- helma-ng/trunk/modules/helma/webapp/continuation.js 2009-05-14 15:27:28 UTC (rev 9757)
+++ helma-ng/trunk/modules/helma/webapp/continuation.js 2009-05-14 15:27:32 UTC (rev 9758)
@@ -8,14 +8,13 @@
var log = require('helma/logging').getLogger(__name__);
importClass(java.util.HashMap);
-function ContinuationSession(req) {
+function ContinuationSession(req, id, step) {
- var id = req.params._cid;
- var data = getData(req) || new HashMap();
+ step = parseInt(step) || 0;
+ var data = getData(req, id);
var pages = [];
var callbacks = [];
var length = 0;
- var step = parseInt(req.params._cstep) || 0;
this.addPage = function(name, callback) {
pages.push(name);
@@ -41,7 +40,10 @@
}
Object.defineProperty(this, "data", {
- value: new ScriptableMap(data)
+ get: function() {
+ data = data || new HashMap();
+ return new ScriptableMap(data)
+ }
});
Object.defineProperty(this, "page", {
@@ -75,7 +77,7 @@
function getContinuationUrl(step) {
id = id || generateId();
- return req.path + "?_cid=" + id + "&_cstep=" + String(step);
+ return [req.actionPath, id, String(step)].join("/");
}
function generateId() {
@@ -89,7 +91,6 @@
};
var getData = function(req, id) {
- id = id || req.params._cid;
if (!id) {
return null;
}