cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r159059 - cocoon/trunk/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java
Date Fri, 25 Mar 2005 20:39:05 GMT
Author: danielf
Date: Fri Mar 25 12:39:04 2005
New Revision: 159059

URL: http://svn.apache.org/viewcvs?view=rev&rev=159059
Log:
Using FOM wrappers for request session and context, to get the same behaviour as in the original
JXTG.

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java?view=diff&r1=159058&r2=159059
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java Fri
Mar 25 12:39:04 2005
@@ -22,6 +22,7 @@
 
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.components.flow.FlowHelper;
+import org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon;
 import org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptFlowHelper;
 import org.apache.commons.jxpath.DynamicPropertyHandler;
 import org.apache.commons.jxpath.JXPathBeanInfo;
@@ -98,26 +99,38 @@
 
         // first create the "cocoon object":
         final Map cocoon = new HashMap();
+
+        // Needed for the FOM wrappers
+        Context cx = Context.enter();
+        try {
+            //FIXME: we surely need to share the scope as this operation is time consuming
+            Scriptable scope = cx.initStandardObjects();
         
-        // cocoon.request
-        final Request request = ObjectModelHelper.getRequest( objectModel );
-        cocoon.put("request", request);
+            // cocoon.request
+            final Request request = ObjectModelHelper.getRequest( objectModel );
+            cocoon.put("request", new FOM_Cocoon.FOM_Request(scope, request));
+            
+            // cocoon.session
+            final Session session = request.getSession(false);
+            if (session != null) {
+                cocoon.put("session", new FOM_Cocoon.FOM_Session(scope, session));
+            }
         
-        // cocoon.session
-        final Session session = request.getSession(false);
-        if (session != null) {
-            cocoon.put("session", session);
+            // cocoon.context
+            final org.apache.cocoon.environment.Context context =
+                ObjectModelHelper.getContext( objectModel );
+            cocoon.put("context", new FOM_Cocoon.FOM_Context(scope, context));
+
+        } finally {
+            Context.exit();
         }
-        
-        // cocoon.context
-        cocoon.put("context", ObjectModelHelper.getContext(objectModel));
-        
+            
         // cocoon.continuation
         final Object cont = FlowHelper.getWebContinuation(objectModel);
         if ( cont != null ) {
             cocoon.put("continuation", cont);
         }
-        
+            
         // cocoon.parameters
         if ( parameters != null ) {
             cocoon.put("parameters", Parameters.toProperties(parameters));



Mime
View raw message