r9664 - in helma-ng/trunk: apps/demo modules/helma modules/helma/webapp
[email protected] Thu, 23 Apr 2009 12:36:40 +0200 (CEST)
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <20090423103640.E28D43D0D6@mia> |
Author: hannes
Date: 2009-04-23 12:36:40 +0200 (Thu, 23 Apr 2009)
New Revision: 9664
Added:
helma-ng/trunk/modules/helma/webapp/env.js
Modified:
helma-ng/trunk/apps/demo/actions.js
helma-ng/trunk/modules/helma/webapp.js
helma-ng/trunk/modules/helma/webapp/continuation.js
Log:
Introduce helma/webapp/env module that provides access to the current jack env, request, and config objects. Use this in helma/webapp/continuation to make the API simpler and produce full URLs.
Details at http://dev.helma.org/trac/helma/changeset/9664
Modified: helma-ng/trunk/apps/demo/actions.js
===================================================================
--- helma-ng/trunk/apps/demo/actions.js 2009-04-22 20:37:24 UTC (rev 9663)
+++ helma-ng/trunk/apps/demo/actions.js 2009-04-23 10:36:40 UTC (rev 9664)
@@ -47,37 +47,37 @@
// local data - this is the data that is shared between continuations of this function
var data = {};
var session = new ContinuationSession("welcome", "ask_name", "ask_food", "ask_animal", "result");
- req = session.start(req);
+ req = session.start();
// render intro page
- req = session.step(1).render(req, SkinnedResponse('skins/continuation.html', {
+ req = session.step(1).render(SkinnedResponse('skins/continuation.html', {
session: session,
title: "Continuations",
data: data
}));
- req = session.step(2).render(req, SkinnedResponse('skins/continuation.html', {
+ req = session.step(2).render(SkinnedResponse('skins/continuation.html', {
session: session,
title: "Question 1",
data: data
}));
data.name = req.params.name || data.name;
- req = session.step(3).render(req, SkinnedResponse('skins/continuation.html', {
+ req = session.step(3).render(SkinnedResponse('skins/continuation.html', {
session: session,
title: "Question 2",
data: data
}));
data.food = req.params.food || data.food;
- req = session.step(4).render(req, SkinnedResponse('skins/continuation.html', {
+ req = session.step(4).render(SkinnedResponse('skins/continuation.html', {
session: session,
title: "Question 3",
data: data
}));
data.animal = req.params.animal || data.animal;
- session.step(5).render(req, SkinnedResponse('skins/continuation.html', {
+ session.step(5).render(SkinnedResponse('skins/continuation.html', {
session: session,
title: "Thank you!",
data: data
Modified: helma-ng/trunk/modules/helma/webapp/continuation.js
===================================================================
--- helma-ng/trunk/modules/helma/webapp/continuation.js 2009-04-22 20:37:24 UTC (rev 9663)
+++ helma-ng/trunk/modules/helma/webapp/continuation.js 2009-04-23 10:36:40 UTC (rev 9664)
@@ -18,7 +18,8 @@
}
var length = pages.length;
- this.start = function(req) {
+ this.start = function() {
+ var req = require('helma/webapp/env').req;
if (!req.params.helma_continuation) {
// set query param so helma knows to switch rhino optimization level to -1
throw { redirect: getContinuationUrl(0) };
@@ -44,7 +45,8 @@
return this;
};
- this.render = function(req, res) {
+ this.render = function(res) {
+ var req = require('helma/webapp/env').req;
// capture continuation and store it in callback container
var id = getContinuationId(currentstep + 1);
var continuation = createContinuation();
@@ -71,7 +73,8 @@
};
function getContinuationUrl(step) {
- return "?helma_continuation=" + getContinuationId(step);
+ var req = require('helma/webapp/env').req;
+ return req.path + "?helma_continuation=" + getContinuationId(step);
}
function getContinuationId(step) {
Added: helma-ng/trunk/modules/helma/webapp/env.js
Modified: helma-ng/trunk/modules/helma/webapp.js
===================================================================
--- helma-ng/trunk/modules/helma/webapp.js 2009-04-22 20:37:24 UTC (rev 9663)
+++ helma-ng/trunk/modules/helma/webapp.js 2009-04-23 10:36:40 UTC (rev 9664)
@@ -7,7 +7,6 @@
include('helma/webapp/request');
include('helma/webapp/response');
-import('helma/webapp/continuation', 'continuation');
import('helma/system', 'system');
import('helma/httpserver', 'server');
@@ -30,10 +29,12 @@
if (log.debugEnabled) log.debug('got config: ' + config.toSource());
var req = new Request(env);
- var res;
+ var res = null;
+ // set up jack env, request and config properties in per-request env module
+ var webenv = require('helma/webapp/env');
+ webenv.init(env, req, config);
req.charset = config.charset || 'utf8';
- // res.contentType = config.contentType || 'text/html';
// resolve path and invoke action
var path = req.path;