cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/validation/impl JavaScriptValidator.java
Date Sun, 25 Apr 2004 12:12:09 GMT
sylvain     2004/04/25 05:12:09

  Modified:    .        status.xml
               src/java/org/apache/cocoon/components/flow FlowHelper.java
               src/java/org/apache/cocoon/components/flow/javascript/fom
                        FOM_Cocoon.java FOM_JavaScriptFlowHelper.java
                        FOM_JavaScriptInterpreter.java
               src/blocks/javaflow/java/org/apache/cocoon/components/flow/java
                        AbstractContinuable.java
               src/blocks/javaflow/java/org/apache/cocoon/forms/flow/java
                        FormInstance.java
               src/blocks/woody/java/org/apache/cocoon/woody/binding
                        JavaScriptJXPathBinding.java
               src/blocks/woody/java/org/apache/cocoon/woody/event/impl
                        JavaScriptWidgetListener.java
               src/blocks/woody/java/org/apache/cocoon/woody/flow/javascript
                        woody2.js
               src/blocks/woody/java/org/apache/cocoon/woody/util
                        JavaScriptHelper.java
               src/blocks/woody/java/org/apache/cocoon/woody/validation/impl
                        JavaScriptValidator.java
               src/blocks/forms/java/org/apache/cocoon/forms/binding
                        JavaScriptJXPathBinding.java
               src/blocks/forms/java/org/apache/cocoon/forms/event/impl
                        JavaScriptWidgetListener.java
               src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript
                        Form.js
               src/blocks/forms/java/org/apache/cocoon/forms/util
                        JavaScriptHelper.java
               src/blocks/forms/java/org/apache/cocoon/forms/validation/impl
                        JavaScriptValidator.java
  Log:
  Pass flow data through the object model rather than through request attributes to avoid
to avoid these data to be overwritten by subrequests
  
  Revision  Changes    Path
  1.308     +6 -1      cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/status.xml,v
  retrieving revision 1.307
  retrieving revision 1.308
  diff -u -r1.307 -r1.308
  --- status.xml	24 Apr 2004 01:57:19 -0000	1.307
  +++ status.xml	25 Apr 2004 12:12:08 -0000	1.308
  @@ -212,6 +212,11 @@
     <changes>
   
    <release version="@version@" date="@date@">
  +   <action dev="SW" type="fix">
  +     Moved storage of all flow-related data (viewData, continuation, request, etc) from
request
  +     attributes to object model entries. This allows a view called by sendPage() to also
use
  +     flowscript (using request attributes caused the two calls to mix up their data).
  +   </action>
      <action dev="JH" type="fix">
        Hopefully fixed the source resolving in JSP components finally by using
        standard Cocoon/Avalon Excalibur source resolving. This allows to use all
  
  
  
  1.4       +15 -12    cocoon-2.1/src/java/org/apache/cocoon/components/flow/FlowHelper.java
  
  Index: FlowHelper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/FlowHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FlowHelper.java	5 Mar 2004 13:02:46 -0000	1.3
  +++ FlowHelper.java	25 Apr 2004 12:12:08 -0000	1.4
  @@ -15,8 +15,6 @@
    */
   package org.apache.cocoon.components.flow;
   
  -import org.apache.cocoon.environment.ObjectModelHelper;
  -import org.apache.cocoon.environment.Request;
   import org.mozilla.javascript.Undefined;
   import org.mozilla.javascript.Wrapper;
   
  @@ -29,15 +27,24 @@
    */
   public class FlowHelper {
   
  +    // Constants defining keys in the object model used to store the various objects.
  +    // These constants are private so that access to these objects only go through the
  +    // accessors provided below.
  +    //
  +    // These objects are stored in the object model rather than as request attributes,
  +    // as object model is cloned for subrequests (see EnvironmentWrapper), whereas
  +    // request attributes are shared between the "real" request and all of its
  +    // child requests.
  +
       /**
        * Request attribute name used to store flow context.
        */
  -    public static final String CONTEXT_OBJECT = "cocoon.flow.context";
  +    private static final String CONTEXT_OBJECT = "cocoon.flow.context";
   
       /**
        * Request attribute name used to store flow continuation.
        */
  -    public static final String CONTINUATION_OBJECT = "cocoon.flow.continuation";
  +    private static final String CONTINUATION_OBJECT = "cocoon.flow.continuation";
   
       /**
        * Get the flow context object associated with the current request
  @@ -46,8 +53,7 @@
        * @return The context object 
        */
       public final static Object getContextObject(Map objectModel) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        return request.getAttribute(CONTEXT_OBJECT);
  +        return objectModel.get(CONTEXT_OBJECT);
       }
   
       /**
  @@ -57,8 +63,7 @@
        * @return The web continuation
        */
       public final static WebContinuation getWebContinuation(Map objectModel) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        return (WebContinuation)request.getAttribute(CONTINUATION_OBJECT);
  +        return (WebContinuation)objectModel.get(CONTINUATION_OBJECT);
       }
   
       /**
  @@ -69,8 +74,7 @@
        */
       public final static void setWebContinuation(Map objectModel,
                                             WebContinuation kont) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        request.setAttribute(CONTINUATION_OBJECT, kont);
  +        objectModel.put(CONTINUATION_OBJECT, kont);
       }
   
       /**
  @@ -80,8 +84,7 @@
        * @param obj The context object 
        */
       public final static void setContextObject(Map objectModel, Object obj) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        request.setAttribute(CONTEXT_OBJECT, obj);
  +        objectModel.put(CONTEXT_OBJECT, obj);
       }
       
       /**
  
  
  
  1.33      +3 -5      cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java
  
  Index: FOM_Cocoon.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- FOM_Cocoon.java	9 Apr 2004 19:52:54 -0000	1.32
  +++ FOM_Cocoon.java	25 Apr 2004 12:12:08 -0000	1.33
  @@ -231,10 +231,8 @@
   
       void popCallContext() {
           // Clear the scope attribute
  -        Request request = this.getRequest();
  -        if (request != null) {
  -            request.removeAttribute(FOM_JavaScriptFlowHelper.FOM_SCOPE);
  -        }
  +        FOM_JavaScriptFlowHelper.setFOM_FlowScope(this.getObjectModel(), null);
  +
           this.currentCall = this.currentCall.caller;
           // reset current page locals
           if (this.currentCall != null) {
  
  
  
  1.5       +53 -39    cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptFlowHelper.java
  
  Index: FOM_JavaScriptFlowHelper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptFlowHelper.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FOM_JavaScriptFlowHelper.java	5 Mar 2004 13:02:46 -0000	1.4
  +++ FOM_JavaScriptFlowHelper.java	25 Apr 2004 12:12:08 -0000	1.5
  @@ -16,8 +16,6 @@
   package org.apache.cocoon.components.flow.javascript.fom;
   
   import org.apache.cocoon.components.flow.FlowHelper;
  -import org.apache.cocoon.environment.ObjectModelHelper;
  -import org.apache.cocoon.environment.Request;
   
   import org.mozilla.javascript.Scriptable;
   
  @@ -33,24 +31,32 @@
    */
   public class FOM_JavaScriptFlowHelper extends FlowHelper {
   
  -    public static final String PACKAGES_OBJECT =
  +    // Constants defining keys in the object model used to store the various objects.
  +    // These constants are private so that access to these objects only go through the
  +    // accessors provided below.
  +    //
  +    // These objects are stored in the object model rather than as request attributes,
  +    // as object model is cloned for subrequests (see EnvironmentWrapper), whereas
  +    // request attributes are shared between the "real" request and all of its
  +    // child requests.
  +    private static final String PACKAGES_OBJECT =
           "cocoon.flow.js.packages";
  -    public static final String JAVA_PACKAGE_OBJECT =
  +    private static final String JAVA_PACKAGE_OBJECT =
           "cocoon.flow.js.packages.java";
  -    public static final String FOM_REQUEST =
  +    private static final String FOM_REQUEST =
           "cocoon.flow.js.fom.FOM_Request";
  -    public static final String FOM_RESPONSE =
  +    private static final String FOM_RESPONSE =
           "cocoon.flow.js.fom.FOM_Response";
  -    public static final String FOM_SESSION =
  +    private static final String FOM_SESSION =
           "cocoon.flow.js.fom.FOM_Session";
  -    public static final String FOM_CONTEXT =
  +    private static final String FOM_CONTEXT =
           "cocoon.flow.js.fom.FOM_Context";
  -    public static final String FOM_WEB_CONTINUATION =
  +    private static final String FOM_WEB_CONTINUATION =
           "cocoon.flow.js.fom.FOM_WebContinuation";
       /**
        * The parent scope to be used by nested scripts (e.g. Woody event handlers)
        */
  -    public static final String FOM_SCOPE =
  +    private static final String FOM_SCOPE =
           "cocoon.flow.js.fom.FOM_Scope";
   
       /**
  @@ -60,8 +66,7 @@
        * @return The Packages property
        */
       public static Scriptable getPackages(Map objectModel) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        return (Scriptable)request.getAttribute(PACKAGES_OBJECT);
  +        return (Scriptable)objectModel.get(PACKAGES_OBJECT);
       }
   
       /**
  @@ -69,8 +74,7 @@
        * @param objectModel The Cocoon Environment's object model
        */
       public static void setPackages(Map objectModel, Scriptable pkgs) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        request.setAttribute(PACKAGES_OBJECT, pkgs);
  +        objectModel.put(PACKAGES_OBJECT, pkgs);
       }
   
       /**
  @@ -80,8 +84,7 @@
        * @return The java package property
        */
       public static Scriptable getJavaPackage(Map objectModel) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        return (Scriptable)request.getAttribute(JAVA_PACKAGE_OBJECT);
  +        return (Scriptable)objectModel.get(JAVA_PACKAGE_OBJECT);
       }
   
       /**
  @@ -89,58 +92,69 @@
        * @param objectModel The Cocoon Environment's object model
        */
       public static void setJavaPackage(Map objectModel, Scriptable javaPkg) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        request.setAttribute(JAVA_PACKAGE_OBJECT, javaPkg);
  +        objectModel.put(JAVA_PACKAGE_OBJECT, javaPkg);
       }
   
       public static Scriptable getFOM_Request(Map objectModel) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        return (Scriptable)request.getAttribute(FOM_REQUEST);
  +        return (Scriptable)objectModel.get(FOM_REQUEST);
       }
   
       public static void setFOM_Request(Map objectModel, Scriptable fom_request) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        request.setAttribute(FOM_REQUEST, fom_request);
  +        objectModel.put(FOM_REQUEST, fom_request);
       }
   
       public static Scriptable getFOM_Response(Map objectModel) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        return (Scriptable)request.getAttribute(FOM_RESPONSE);
  +        return (Scriptable)objectModel.get(FOM_RESPONSE);
       }
   
       public static void setFOM_Response(Map objectModel, Scriptable fom_response) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        request.setAttribute(FOM_RESPONSE, fom_response);
  +        objectModel.put(FOM_RESPONSE, fom_response);
       }
   
       public static Scriptable getFOM_Session(Map objectModel) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        return (Scriptable)request.getAttribute(FOM_SESSION);
  +        return (Scriptable)objectModel.get(FOM_SESSION);
       }
   
       public static void setFOM_Session(Map objectModel, Scriptable fom_session) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        request.setAttribute(FOM_SESSION, fom_session);
  +        objectModel.put(FOM_SESSION, fom_session);
       }
   
       public static Scriptable getFOM_Context(Map objectModel) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        return (Scriptable)request.getAttribute(FOM_CONTEXT);
  +        return (Scriptable)objectModel.get(FOM_CONTEXT);
       }
   
       public static void setFOM_Context(Map objectModel, Scriptable fom_context) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        request.setAttribute(FOM_CONTEXT, fom_context);
  +        objectModel.put(FOM_CONTEXT, fom_context);
       }
   
       public static Scriptable getFOM_WebContinuation(Map objectModel) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        return (Scriptable)request.getAttribute(FOM_WEB_CONTINUATION);
  +        return (Scriptable)objectModel.get(FOM_WEB_CONTINUATION);
       }
   
       public static void setFOM_WebContinuation(Map objectModel,
                                                 Scriptable fom_webContinuation) {
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        request.setAttribute(FOM_WEB_CONTINUATION, fom_webContinuation);
  +        objectModel.put(FOM_WEB_CONTINUATION, fom_webContinuation);
  +    }
  +    
  +    /**
  +     * Get the flowscript scope, usable by JS snippets part of the control layer, such
  +     * as forms event listeners.
  +     * 
  +     * @param objectModel the object model where the scope is stored
  +     * @return the flowscript scope
  +     */
  +    public static Scriptable getFOM_FlowScope(Map objectModel) {
  +        return (Scriptable)objectModel.get(FOM_SCOPE);
  +    }
  +    
  +    /**
  +     * Set the flowscript scope usable by JS snippets.
  +     * 
  +     * @see #getFOM_FlowScope(Map)
  +     * @param objectModel
  +     * @param fom_scope
  +     */
  +    public static void setFOM_FlowScope(Map objectModel, Scriptable fom_scope) {
  +        objectModel.put(FOM_SCOPE, fom_scope);
       }
   }
  
  
  
  1.27      +3 -5      cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
  
  Index: FOM_JavaScriptInterpreter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- FOM_JavaScriptInterpreter.java	24 Apr 2004 17:38:32 -0000	1.26
  +++ FOM_JavaScriptInterpreter.java	25 Apr 2004 12:12:08 -0000	1.27
  @@ -669,8 +669,7 @@
                       cocoon = (FOM_Cocoon)thrScope.get("cocoon", thrScope);
                       
                       // Register the current scope for scripts indirectly called from this
function
  -                    cocoon.getRequest().setAttribute(
  -                                                     FOM_JavaScriptFlowHelper.FOM_SCOPE,
thrScope);
  +                    FOM_JavaScriptFlowHelper.setFOM_FlowScope(cocoon.getObjectModel(),
thrScope);
                       if (enableDebugger) {
                           if (!getDebugger().isVisible()) {
                               // only raise the debugger window if it isn't already visible
  @@ -762,8 +761,7 @@
                                          avalonContext,
                                          getLogger(), wk);
                   // Register the current scope for scripts indirectly called from this function
  -                cocoon.getRequest().setAttribute(
  -                                                 FOM_JavaScriptFlowHelper.FOM_SCOPE, kScope);
  +                FOM_JavaScriptFlowHelper.setFOM_FlowScope(cocoon.getObjectModel(), kScope);
                   
                   if (enableDebugger) {
                       getDebugger().setVisible(true);
  
  
  
  1.3       +6 -1      cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/AbstractContinuable.java
  
  Index: AbstractContinuable.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/AbstractContinuable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractContinuable.java	16 Apr 2004 09:39:57 -0000	1.2
  +++ AbstractContinuable.java	25 Apr 2004 12:12:08 -0000	1.3
  @@ -24,6 +24,7 @@
   import org.apache.excalibur.source.SourceUtil;
   
   import java.io.OutputStream;
  +import java.util.Map;
   
   /**
    * Abstract class to add basic methods for flow handling.
  @@ -104,6 +105,10 @@
   
       public Request getRequest() {
           return ContextHelper.getRequest(getContext().getAvalonContext());
  +    }
  +    
  +    public Map getObjectModel() {
  +        return ContextHelper.getObjectModel(getContext().getAvalonContext());
       }
   
       public void processPipelineTo(String uri, Object bizdata, OutputStream out) {
  
  
  
  1.8       +2 -2      cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/forms/flow/java/FormInstance.java
  
  Index: FormInstance.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/forms/flow/java/FormInstance.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FormInstance.java	24 Apr 2004 00:00:42 -0000	1.7
  +++ FormInstance.java	25 Apr 2004 12:12:08 -0000	1.8
  @@ -189,7 +189,7 @@
   
               // Prematurely add the bizData as a request attribute so that event listeners
can use it
               // (the same is done by cocoon.sendPage())
  -            getRequest().setAttribute(FlowHelper.CONTEXT_OBJECT, bizData);
  +            FlowHelper.setContextObject(this.getObjectModel(), bizData);
   
               finished = this.form.process(formContext);
             
  
  
  
  1.12      +5 -5      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JavaScriptJXPathBinding.java
  
  Index: JavaScriptJXPathBinding.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JavaScriptJXPathBinding.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JavaScriptJXPathBinding.java	9 Mar 2004 13:54:06 -0000	1.11
  +++ JavaScriptJXPathBinding.java	25 Apr 2004 12:12:08 -0000	1.12
  @@ -59,7 +59,7 @@
       
               // FIXME: remove this ugly hack and get the request from the
               // Avalon context once binding builder are real components
  -            Request request = ObjectModelHelper.getRequest(CocoonComponentManager.getCurrentEnvironment().getObjectModel());
  +            Map objectModel = CocoonComponentManager.getCurrentEnvironment().getObjectModel();
   
               try {
                   Map values = new HashMap(3);
  @@ -69,7 +69,7 @@
                       values.put("jxpathContext", jctx.getRelativeContext(pointer));
                   }
   
  -                JavaScriptHelper.execScript(this.loadScript, values, request);
  +                JavaScriptHelper.execScript(this.loadScript, values, objectModel);
       
               } catch(RuntimeException re) {
                   // rethrow
  @@ -94,14 +94,14 @@
               try {
                   // FIXME: remove this ugly hack and get the request from the Avalon context
once
                   // binding builder are real components
  -                Request request = ObjectModelHelper.getRequest(CocoonComponentManager.getCurrentEnvironment().getObjectModel());
  +                Map objectModel = CocoonComponentManager.getCurrentEnvironment().getObjectModel();
   
                   Map values = new HashMap();
                   values.put("widget", widget);
                   values.put("jxpathContext", widgetCtx);
                   values.put("jxpathPointer", pointer);
   
  -                JavaScriptHelper.execScript(this.saveScript, values, request);
  +                JavaScriptHelper.execScript(this.saveScript, values, objectModel);
   
               } catch(RuntimeException re) {
                   // rethrow
  
  
  
  1.8       +5 -4      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/event/impl/JavaScriptWidgetListener.java
  
  Index: JavaScriptWidgetListener.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/event/impl/JavaScriptWidgetListener.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JavaScriptWidgetListener.java	9 Mar 2004 13:54:26 -0000	1.7
  +++ JavaScriptWidgetListener.java	25 Apr 2004 12:12:08 -0000	1.8
  @@ -16,6 +16,7 @@
   package org.apache.cocoon.woody.event.impl;
   
   import java.util.HashMap;
  +import java.util.Map;
   
   import org.apache.avalon.framework.CascadingRuntimeException;
   import org.apache.cocoon.components.CocoonComponentManager;
  @@ -55,15 +56,15 @@
               
               // FIXME: remove this ugly hack and get the request from the Avalon context
once
               // listener builder are real components
  -            Request request = ObjectModelHelper.getRequest(CocoonComponentManager.getCurrentEnvironment().getObjectModel());
  +            Map objectModel = CocoonComponentManager.getCurrentEnvironment().getObjectModel();
               
               // Add the biz data that was passed to showForm()
  -            Object viewData = request.getAttribute(FlowHelper.CONTEXT_OBJECT);
  +            Object viewData = FlowHelper.getContextObject(objectModel);
               if (viewData != null) {
                   values.put("viewData", viewData);
               }
               
  -            JavaScriptHelper.execScript(this.script, values, request);
  +            JavaScriptHelper.execScript(this.script, values, objectModel);
               
           } catch(RuntimeException re) {
               // rethrow
  
  
  
  1.13      +3 -1      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/flow/javascript/woody2.js
  
  Index: woody2.js
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/flow/javascript/woody2.js,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- woody2.js	18 Mar 2004 14:01:44 -0000	1.12
  +++ woody2.js	25 Apr 2004 12:12:08 -0000	1.13
  @@ -108,7 +108,9 @@
   
           // Prematurely add the bizData as a request attribute so that event listeners can
use it
           // (the same is done by cocoon.sendPage())
  -        cocoon.request.setAttribute(Packages.org.apache.cocoon.components.flow.FlowHelper.CONTEXT_OBJECT,
bizData);
  +        // FIXME: hack because object model isn't available in flowscript.
  +        var objectModel = org.apache.cocoon.components.CocoonComponentManager.getCurrentEnvironment().getObjectModel();
  +        org.apache.cocoon.components.flow.FlowHelper.setContextObject(objectModel, bizData);
   
           finished = this.form.process(formContext);
           
  
  
  
  1.8       +12 -12    cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/util/JavaScriptHelper.java
  
  Index: JavaScriptHelper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/util/JavaScriptHelper.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JavaScriptHelper.java	9 Mar 2004 13:54:24 -0000	1.7
  +++ JavaScriptHelper.java	25 Apr 2004 12:12:08 -0000	1.8
  @@ -136,11 +136,11 @@
        * @param request a request where the flowscript scope will be searched (can be <code>null</code>).
        * @return an appropriate parent scope.
        */
  -    public static Scriptable getParentScope(Request request) {
  +    public static Scriptable getParentScope(Map objectModel) {
           // Try to get the flowscript scope
           Scriptable parentScope = null;
  -        if (request != null) {
  -            parentScope = (Scriptable)request.getAttribute(FOM_JavaScriptFlowHelper.FOM_SCOPE);
  +        if (objectModel != null) {
  +            parentScope = FOM_JavaScriptFlowHelper.getFOM_FlowScope(objectModel);
           }
   
           if (parentScope != null) {
  @@ -150,10 +150,10 @@
           }
       }
   
  -    public static Object execScript(Script script, Map values, Request request) throws
JavaScriptException {
  +    public static Object execScript(Script script, Map values, Map objectModel) throws
JavaScriptException {
           Context ctx = Context.enter();
           try {
  -            Scriptable parentScope = getParentScope(request);
  +            Scriptable parentScope = getParentScope(objectModel);
   
               // Create a new local scope
               Scriptable scope;
  @@ -174,8 +174,8 @@
                   scope.put(key, scope, Context.toObject(value, scope));
               }
               
  -            if (request != null) {
  -                Object viewData = request.getAttribute(FlowHelper.CONTEXT_OBJECT);
  +            if (objectModel != null) {
  +                Object viewData = FlowHelper.getContextObject(objectModel);
                   if (viewData != null) {
                       scope.put("viewData", scope, Context.toObject(viewData, scope));
                   }
  @@ -188,13 +188,13 @@
           }
       }
       
  -    public static Object callFunction(Function func, Object thisObject, Object[] arguments,
Request request) throws JavaScriptException {
  +    public static Object callFunction(Function func, Object thisObject, Object[] arguments,
Map objectModel) throws JavaScriptException {
           Context ctx = Context.enter();
           try {
  -            Scriptable scope = getParentScope(request);
  +            Scriptable scope = getParentScope(objectModel);
   
  -            if (request != null) {
  -                Object viewData = request.getAttribute(FlowHelper.CONTEXT_OBJECT);
  +            if (objectModel != null) {
  +                Object viewData = FlowHelper.getContextObject(objectModel);
                   if (viewData != null) {
                       // Create a new local scope to hold the view data
                       Scriptable newScope;
  
  
  
  1.5       +5 -3      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/validation/impl/JavaScriptValidator.java
  
  Index: JavaScriptValidator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/validation/impl/JavaScriptValidator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JavaScriptValidator.java	9 Mar 2004 13:54:24 -0000	1.4
  +++ JavaScriptValidator.java	25 Apr 2004 12:12:08 -0000	1.5
  @@ -15,6 +15,8 @@
    */
   package org.apache.cocoon.woody.validation.impl;
   
  +import java.util.Map;
  +
   import org.apache.avalon.framework.CascadingRuntimeException;
   import org.apache.avalon.framework.context.Context;
   import org.apache.cocoon.components.ContextHelper;
  @@ -51,12 +53,12 @@
        */
       public final boolean validate(Widget widget, FormContext context) {
   
  -        Request request = ContextHelper.getRequest(this.avalonContext);
  +        Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
   
           Object result;
               
           try {
  -            result = JavaScriptHelper.callFunction(this.function, widget, new Object[]
{widget}, request);
  +            result = JavaScriptHelper.callFunction(this.function, widget, new Object[]
{widget}, objectModel);
           } catch(RuntimeException re) {
               throw re; // rethrow
           } catch(Exception e) {
  
  
  
  1.4       +5 -5      cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/binding/JavaScriptJXPathBinding.java
  
  Index: JavaScriptJXPathBinding.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/binding/JavaScriptJXPathBinding.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JavaScriptJXPathBinding.java	23 Apr 2004 11:42:58 -0000	1.3
  +++ JavaScriptJXPathBinding.java	25 Apr 2004 12:12:09 -0000	1.4
  @@ -59,7 +59,7 @@
       
               // FIXME: remove this ugly hack and get the request from the
               // Avalon context once binding builder are real components
  -            Request request = ObjectModelHelper.getRequest(CocoonComponentManager.getCurrentEnvironment().getObjectModel());
  +            Map objectModel = CocoonComponentManager.getCurrentEnvironment().getObjectModel();
   
               try {
                   Map values = new HashMap(3);
  @@ -69,7 +69,7 @@
                       values.put("jxpathContext", jctx.getRelativeContext(pointer));
                   }
   
  -                JavaScriptHelper.execScript(this.loadScript, values, request);
  +                JavaScriptHelper.execScript(this.loadScript, values, objectModel);
       
               } catch(RuntimeException re) {
                   // rethrow
  @@ -94,14 +94,14 @@
               try {
                   // FIXME: remove this ugly hack and get the request from the Avalon context
once
                   // binding builder are real components
  -                Request request = ObjectModelHelper.getRequest(CocoonComponentManager.getCurrentEnvironment().getObjectModel());
  +                Map objectModel = CocoonComponentManager.getCurrentEnvironment().getObjectModel();
   
                   Map values = new HashMap();
                   values.put("widget", widget);
                   values.put("jxpathContext", widgetCtx);
                   values.put("jxpathPointer", pointer);
   
  -                JavaScriptHelper.execScript(this.saveScript, values, request);
  +                JavaScriptHelper.execScript(this.saveScript, values, objectModel);
   
               } catch(RuntimeException re) {
                   // rethrow
  
  
  
  1.3       +5 -4      cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/event/impl/JavaScriptWidgetListener.java
  
  Index: JavaScriptWidgetListener.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/event/impl/JavaScriptWidgetListener.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JavaScriptWidgetListener.java	9 Mar 2004 11:31:12 -0000	1.2
  +++ JavaScriptWidgetListener.java	25 Apr 2004 12:12:09 -0000	1.3
  @@ -16,6 +16,7 @@
   package org.apache.cocoon.forms.event.impl;
   
   import java.util.HashMap;
  +import java.util.Map;
   
   import org.apache.avalon.framework.CascadingRuntimeException;
   import org.apache.cocoon.components.CocoonComponentManager;
  @@ -55,15 +56,15 @@
               
               // FIXME: remove this ugly hack and get the request from the Avalon context
once
               // listener builder are real components
  -            Request request = ObjectModelHelper.getRequest(CocoonComponentManager.getCurrentEnvironment().getObjectModel());
  +            Map objectModel = CocoonComponentManager.getCurrentEnvironment().getObjectModel();
               
               // Add the biz data that was passed to showForm()
  -            Object viewData = request.getAttribute(FlowHelper.CONTEXT_OBJECT);
  +            Object viewData = FlowHelper.getContextObject(objectModel);
               if (viewData != null) {
                   values.put("viewData", viewData);
               }
               
  -            JavaScriptHelper.execScript(this.script, values, request);
  +            JavaScriptHelper.execScript(this.script, values, objectModel);
               
           } catch(RuntimeException re) {
               // rethrow
  
  
  
  1.6       +5 -3      cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/Form.js
  
  Index: Form.js
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/Form.js,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Form.js	31 Mar 2004 21:06:59 -0000	1.5
  +++ Form.js	25 Apr 2004 12:12:09 -0000	1.6
  @@ -106,9 +106,11 @@
           var formContext = 
               Packages.org.apache.cocoon.forms.flow.javascript.FormsFlowHelper.getFormContext(cocoon,
this.locale);
   
  -        // Prematurely add the bizData as a request attribute so that event listeners can
use it
  +        // Prematurely add the bizData as in the object model so that event listeners can
use it
           // (the same is done by cocoon.sendPage())
  -        cocoon.request.setAttribute(Packages.org.apache.cocoon.components.flow.FlowHelper.CONTEXT_OBJECT,
bizData);
  +        // FIXME: hack because object model isn't available in flowscript.
  +        var objectModel = org.apache.cocoon.components.CocoonComponentManager.getCurrentEnvironment().getObjectModel();
  +        org.apache.cocoon.components.flow.FlowHelper.setContextObject(objectModel, bizData);
   
           finished = this.form.process(formContext);
           
  
  
  
  1.3       +13 -13    cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/util/JavaScriptHelper.java
  
  Index: JavaScriptHelper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/util/JavaScriptHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JavaScriptHelper.java	11 Mar 2004 02:56:32 -0000	1.2
  +++ JavaScriptHelper.java	25 Apr 2004 12:12:09 -0000	1.3
  @@ -133,14 +133,14 @@
        * that can be provided by a flowscript higher in the call stack, giving visibility
to flowscript
        * functions and global (session) variables.
        * 
  -     * @param request a request where the flowscript scope will be searched (can be <code>null</code>).
  +     * @param objectModel the object model where the flowscript scope will be searched
(can be <code>null</code>).
        * @return an appropriate parent scope.
        */
  -    public static Scriptable getParentScope(Request request) {
  +    public static Scriptable getParentScope(Map objectModel) {
           // Try to get the flowscript scope
           Scriptable parentScope = null;
  -        if (request != null) {
  -            parentScope = (Scriptable)request.getAttribute(FOM_JavaScriptFlowHelper.FOM_SCOPE);
  +        if (objectModel != null) {
  +            parentScope = FOM_JavaScriptFlowHelper.getFOM_FlowScope(objectModel);
           }
   
           if (parentScope != null) {
  @@ -150,10 +150,10 @@
           }
       }
   
  -    public static Object execScript(Script script, Map values, Request request) throws
JavaScriptException {
  +    public static Object execScript(Script script, Map values, Map objectModel) throws
JavaScriptException {
           Context ctx = Context.enter();
           try {
  -            Scriptable parentScope = getParentScope(request);
  +            Scriptable parentScope = getParentScope(objectModel);
   
               // Create a new local scope
               Scriptable scope;
  @@ -174,8 +174,8 @@
                   scope.put(key, scope, Context.toObject(value, scope));
               }
               
  -            if (request != null) {
  -                Object viewData = request.getAttribute(FlowHelper.CONTEXT_OBJECT);
  +            if (objectModel != null) {
  +                Object viewData = FlowHelper.getContextObject(objectModel);
                   if (viewData != null) {
                       scope.put("viewData", scope, Context.toObject(viewData, scope));
                   }
  @@ -188,13 +188,13 @@
           }
       }
       
  -    public static Object callFunction(Function func, Object thisObject, Object[] arguments,
Request request) throws JavaScriptException {
  +    public static Object callFunction(Function func, Object thisObject, Object[] arguments,
Map objectModel) throws JavaScriptException {
           Context ctx = Context.enter();
           try {
  -            Scriptable scope = getParentScope(request);
  +            Scriptable scope = getParentScope(objectModel);
   
  -            if (request != null) {
  -                Object viewData = request.getAttribute(FlowHelper.CONTEXT_OBJECT);
  +            if (objectModel != null) {
  +                Object viewData = FlowHelper.getContextObject(objectModel);
                   if (viewData != null) {
                       // Create a new local scope to hold the view data
                       Scriptable newScope;
  
  
  
  1.3       +5 -3      cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidator.java
  
  Index: JavaScriptValidator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JavaScriptValidator.java	9 Mar 2004 11:31:11 -0000	1.2
  +++ JavaScriptValidator.java	25 Apr 2004 12:12:09 -0000	1.3
  @@ -15,6 +15,8 @@
    */
   package org.apache.cocoon.forms.validation.impl;
   
  +import java.util.Map;
  +
   import org.apache.avalon.framework.CascadingRuntimeException;
   import org.apache.avalon.framework.context.Context;
   import org.apache.cocoon.components.ContextHelper;
  @@ -51,12 +53,12 @@
        */
       public final boolean validate(Widget widget, FormContext context) {
   
  -        Request request = ContextHelper.getRequest(this.avalonContext);
  +        Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
   
           Object result;
               
           try {
  -            result = JavaScriptHelper.callFunction(this.function, widget, new Object[]
{widget}, request);
  +            result = JavaScriptHelper.callFunction(this.function, widget, new Object[]
{widget}, objectModel);
           } catch(RuntimeException re) {
               throw re; // rethrow
           } catch(Exception e) {
  
  
  

Mime
View raw message