r9750 - helma-ng/trunk/modules/helma/webapp
[email protected] Thu, 14 May 2009 15:18:24 +0200 (CEST)
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <20090514131824.09E8C3D0D6@mia> |
Author: hannes
Date: 2009-05-14 15:18:23 +0200 (Thu, 14 May 2009)
New Revision: 9750
Modified:
helma-ng/trunk/modules/helma/webapp/request.js
Log:
Rewrite req.session a JavaAdapter that directly proxies property access to the attributes in the servlet session object.
This is necessary for environments that can't deal with scriptable objects because of serialization issues.
Details at http://dev.helma.org/trac/helma/changeset/9750
Modified: helma-ng/trunk/modules/helma/webapp/request.js
===================================================================
--- helma-ng/trunk/modules/helma/webapp/request.js 2009-05-14 13:18:19 UTC (rev 9749)
+++ helma-ng/trunk/modules/helma/webapp/request.js 2009-05-14 13:18:23 UTC (rev 9750)
@@ -1,6 +1,8 @@
require('core/string');
include('helma/functional');
include('helma/util');
+importClass(org.mozilla.javascript.Context);
+importClass(org.mozilla.javascript.Scriptable);
export('Request');
@@ -96,14 +98,16 @@
define("data", {
get: function() {
if (!data) {
- var session = getSession();
- data = session.getAttribute("helma");
- if (!data) {
- data = new ScriptableMap();
- session.setAttribute("helma", data);
- } else {
- data = new ScriptableMap(data);
- }
+ // session.data is a JavaAdapter that directly proxies property access
+ // to the attributes in the servlet session object.
+ data = new JavaAdapter(Scriptable, {
+ put: function(name, start, value) {
+ getSession().setAttribute(name, Context.jsToJava(value, java.lang.Object));
+ },
+ get: function(name, start) {
+ return Context.javaToJS(getSession().getAttribute(name), global);
+ }
+ });
}
return data;
}