You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by co...@apache.org on 2003/05/07 06:36:34 UTC

cvs commit: cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation FlowVelocityGenerator.java JXFormsGenerator.java JXTemplateGenerator.java TraxGenerator.java

coliver     2003/05/06 21:36:34

  Modified:    src/blocks/xmlform/java/org/apache/cocoon/transformation
                        XMLFormTransformer.java
               src/java/org/apache/cocoon/components/flow
                        AbstractInterpreter.java Interpreter.java
               src/java/org/apache/cocoon/components/flow/javascript
                        JSCocoon.java JavaScriptInterpreter.java
               src/java/org/apache/cocoon/components/language/markup/xsp/java
                        jpath.xsl
               src/java/org/apache/cocoon/transformation
                        JPathTransformer.java
               src/scratchpad/src/org/apache/cocoon/generation
                        FlowVelocityGenerator.java JXFormsGenerator.java
                        JXTemplateGenerator.java TraxGenerator.java
  Added:       src/java/org/apache/cocoon/components/flow Flow.java
               src/java/org/apache/cocoon/components/flow/javascript
                        JavaScriptFlow.java
  Log:
  Pass flow context object and web continuation to views as request parameters instead of environment attributes
  
  Revision  Changes    Path
  1.3       +5 -3      cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation/XMLFormTransformer.java
  
  Index: XMLFormTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLFormTransformer.java	26 Apr 2003 12:10:44 -0000	1.2
  +++ XMLFormTransformer.java	7 May 2003 04:36:32 -0000	1.3
  @@ -70,6 +70,7 @@
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
   import org.apache.cocoon.components.flow.WebContinuation;
  +import org.apache.cocoon.components.flow.Flow;
   import org.apache.cocoon.environment.Environment;
   
   /**
  @@ -502,9 +503,10 @@
                           String continuation = attributes.getValue("continuation");
   
                           if (continuation!=null) {
  -                            WebContinuation kont = (WebContinuation) ((Environment) resolver).getAttribute("kont");
  +                            WebContinuation kont = 
  +				Flow.getWebContinuation(objectModel);
   
  -                            if (kont!=null) {
  +                            if (kont != null) {
                                   int level = 0;
   
                                   if (continuation.equals("back")) {
  
  
  
  1.3       +6 -15     cocoon-2.1/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java
  
  Index: AbstractInterpreter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractInterpreter.java	16 Mar 2003 17:49:11 -0000	1.2
  +++ AbstractInterpreter.java	7 May 2003 04:36:33 -0000	1.3
  @@ -66,7 +66,7 @@
   
   import java.io.OutputStream;
   import java.util.ArrayList;
  -
  +import java.util.Map;
   /**
    * Abstract superclass for various scripting languages used by Cocoon
    * for flow control. Defines some useful behavior like the ability to
  @@ -219,18 +219,9 @@
                           Environment environment)
       throws Exception
     {
  -    environment.setAttribute("bean-dict", bizData);
  -    if (continuation != null)
  -      environment.setAttribute("kont", continuation);
  -
  -    try {
  -      PipelinesNode.getRedirector(environment)
  -        .redirect(false, uri);
  -    }
  -    finally {
  -      environment.removeAttribute("bean-dict");
  -      if (continuation != null)
  -        environment.removeAttribute("kont");
  -    }
  +    Map objectModel = environment.getObjectModel();
  +    Flow.setContextObject(objectModel, bizData);
  +    Flow.setWebContinuation(objectModel, continuation);
  +    PipelinesNode.getRedirector(environment).redirect(false, uri);
     }
   }
  
  
  
  1.3       +3 -1      cocoon-2.1/src/java/org/apache/cocoon/components/flow/Interpreter.java
  
  Index: Interpreter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/Interpreter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Interpreter.java	16 Mar 2003 17:49:11 -0000	1.2
  +++ Interpreter.java	7 May 2003 04:36:33 -0000	1.3
  @@ -113,6 +113,8 @@
    */
   public interface Interpreter
   {
  +
  +
     public static class Argument
     {
       public String name;
  
  
  
  1.1                  cocoon-2.1/src/java/org/apache/cocoon/components/flow/Flow.java
  
  Index: Flow.java
  ===================================================================
  /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
  */
  package org.apache.cocoon.components.flow;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.environment.Request;
  import java.util.Map;
  
  /**
   * Provides the interface between the flow controller layer and the 
   * view layer. A view can obtain the context object sent by a flow
   * script and the current web continuation, if any.
   */
  
  public class Flow {
  
      public static String CONTEXT_OBJECT_KEY = "cocoon.flow.context";
      public static String WEB_CONTINUATION_KEY = "cocoon.flow.webcontinuation";
  
      /**
       * Get the flow context object associated with the current request
       * @param objectModel The Cocoon Environment's object model
       * @return The context object 
       */
      public static Object getContextObject(Map objectModel) {
  	Request request = ObjectModelHelper.getRequest(objectModel);
  	return request.getAttribute(CONTEXT_OBJECT_KEY);
      }
  
      /**
       *
       * Get the web continuation associated with the current request
       * @param objectModel The Cocoon Environment's object model
       * @return The web continuation
       *
       */
      public static WebContinuation getWebContinuation(Map objectModel) {
  	Request request = ObjectModelHelper.getRequest(objectModel);
  	return (WebContinuation)request.getAttribute(WEB_CONTINUATION_KEY);
      }
  
      /**
       *
       * Set the web continuation associated with the current request
       * @param objectModel The Cocoon Environment's object model
       * @param kont The web continuation
       *
       */
      public static void setWebContinuation(Map objectModel,
  					  WebContinuation kont) {
  	Request request = ObjectModelHelper.getRequest(objectModel);
  	request.setAttribute(WEB_CONTINUATION_KEY, kont);
      }
  
      /**
       * Set the flow context object associated with the current request
       * @param objectModel The Cocoon Environment's object model
       * @param obj The context object 
       */
      public static void setContextObject(Map objectModel, Object obj) {
  	Request request = ObjectModelHelper.getRequest(objectModel);
  	request.setAttribute(CONTEXT_OBJECT_KEY, obj);
      }
  
  }
  
  
  
  1.10      +3 -5      cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/JSCocoon.java
  
  Index: JSCocoon.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/JSCocoon.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JSCocoon.java	4 Apr 2003 23:08:13 -0000	1.9
  +++ JSCocoon.java	7 May 2003 04:36:33 -0000	1.10
  @@ -184,9 +184,7 @@
       }
   
       /**
  -     * Load the file specified as argument. Registers the file with the
  -     * interpreter and then forces its loading by calling {@link
  -     * JavaScriptInterpreter#checkForModifiedScripts}.
  +     * Load the script file specified as argument.
        *
        * @param filename a <code>String</code> value
        * @return an <code>Object</code> value
  @@ -264,7 +262,7 @@
           throws JavaScriptException
       {
           try {
  -            environment.redirect(false,uri);
  +            environment.redirect(false, uri);
           } catch (Exception e) {
               throw new JavaScriptException(e);
           }
  
  
  
  1.18      +18 -4     cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java
  
  Index: JavaScriptInterpreter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- JavaScriptInterpreter.java	1 May 2003 09:32:34 -0000	1.17
  +++ JavaScriptInterpreter.java	7 May 2003 04:36:33 -0000	1.18
  @@ -44,7 +44,6 @@
   
   */
   package org.apache.cocoon.components.flow.javascript;
  -
   import java.io.BufferedReader;
   import java.io.InputStream;
   import java.io.InputStreamReader;
  @@ -96,6 +95,7 @@
   public class JavaScriptInterpreter extends AbstractInterpreter
       implements Configurable, Initializable
   {
  +
       /**
        * LAST_EXEC_TIME
        * A long value is stored under this key in each top level JavaScript 
  @@ -349,8 +349,7 @@
        * function="..."&gt;</code>, you need to invoke from the JavaScript
        * script <code>cocoon.createSession()</code>. This will place the
        * newly create Scriptable object in the user's session, where it
  -     * will be retrieved from at the next invocation of
  -     * {@link #callFunction(String, List, Environment))}.</p>
  +     * will be retrieved from at the next invocation of {@link #callFunction}.</p>
        *
        * @param environment an <code>Environment</code> value
        * @return a <code>Scriptable</code> value
  @@ -685,6 +684,21 @@
               return (Throwable)value;
           }
           return e;
  +    }
  +
  +    public void forwardTo(String uri, Object bizData,
  +                          WebContinuation continuation,
  +                          Environment environment)
  +        throws Exception {
  +        Map objectModel = environment.getObjectModel();
  +        // Make the live-connect objects available to the view layer
  +        JavaScriptFlow.setPackages(objectModel, 
  +                                   (Scriptable)ScriptableObject.getProperty(scope,
  +                                                                            "Packages"));
  +        JavaScriptFlow.setJavaPackage(objectModel, 
  +                                      (Scriptable)ScriptableObject.getProperty(scope,
  +                                                                   "java"));
  +        super.forwardTo(uri, bizData, continuation, environment);
       }
   }
   
  
  
  
  1.1                  cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptFlow.java
  
  Index: JavaScriptFlow.java
  ===================================================================
  /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
  */
  package org.apache.cocoon.components.flow.javascript;
  import org.apache.cocoon.components.flow.Flow;
  import org.mozilla.javascript.Scriptable;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.environment.Request;
  import java.util.Map;
  
  /**
   * Provides the interface between the JavaScript flow controller layer and the 
   * view layer. A view can obtain the JavaScript "live connect" objects (that
   * allow access to Java constructors) through this interface
   */
  
  public class JavaScriptFlow extends Flow {
  
      public static final String COCOON_FLOW_JS_PACKAGES =
  	"cocoon.flow.js.rhino.packages";
      public static final String COCOON_FLOW_JS_JAVA_PACKAGE =
  	"cocoon.flow.js.rhino.packages.java";
  
      /** 
       * Return the JS "Packages" property (that gives access to Java
       * packages) for use by the view layer
       * @param objectModel The Cocoon Environment's object model
       * @return The Packages property
       */
      public static Scriptable getPackages(Map objectModel) {
          Request request = ObjectModelHelper.getRequest(objectModel);
          return (Scriptable)request.getAttribute(COCOON_FLOW_JS_PACKAGES);
      }
  
  
      /** 
       * Return the JS "java" property (that gives access to the "java"
       * package) for use by the view layer
       * @param objectModel The Cocoon Environment's object model
       * @return The java package property
       */
      public static Scriptable getJavaPackage(Map objectModel) {
          Request request = ObjectModelHelper.getRequest(objectModel);
          return (Scriptable)request.getAttribute(COCOON_FLOW_JS_JAVA_PACKAGE);
      }
  
  
      /** 
       * Set the JS "Packages" property in the current request
       * @param objectModel The Cocoon Environment's object model
       * @return The Packages property
       */
      public static void setPackages(Map objectModel, Scriptable pkgs) {
          Request request = ObjectModelHelper.getRequest(objectModel);
          request.setAttribute(COCOON_FLOW_JS_PACKAGES, pkgs);
      }
  
      /** 
       * Set the JS "java" property in the current request
       * @param objectModel The Cocoon Environment's object model
       * @return The "java" property
       */
      public static void setJavaPackage(Map objectModel, Scriptable javaPkg) {
          Request request = ObjectModelHelper.getRequest(objectModel);
          request.setAttribute(COCOON_FLOW_JS_JAVA_PACKAGE, javaPkg);
      }
  
  }
  
  
  
  
  1.2       +3 -2      cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/java/jpath.xsl
  
  Index: jpath.xsl
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/java/jpath.xsl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jpath.xsl	9 Mar 2003 00:08:56 -0000	1.1
  +++ jpath.xsl	7 May 2003 04:36:33 -0000	1.2
  @@ -28,6 +28,7 @@
           <xsp:include>java.util.Iterator</xsp:include>
           <xsp:include>org.apache.cocoon.environment.Environment</xsp:include>
           <xsp:include>org.apache.cocoon.components.flow.WebContinuation</xsp:include>
  +        <xsp:include>org.apache.cocoon.components.flow.Flow</xsp:include>
           <xsp:include>org.apache.commons.jxpath.JXPathContext</xsp:include>
           <xsp:include>org.apache.commons.jxpath.CompiledExpression</xsp:include>
         </xsp:structure>
  @@ -36,9 +37,9 @@
         </xsp:logic>
   
         <xsp:init-page>
  -        Object bean = ((Environment)resolver).getAttribute("bean-dict");
  +        Object bean = Flow.getContextObject(this.objectModel);
           WebContinuation kont
  -          = (WebContinuation)((Environment)resolver).getAttribute("kont");
  +          = Flow.getWebContinuation(this.objectModel);
           JXPathContext jxpathContext = JXPathContext.newContext(bean);
           Object __jxpathResult;
           // Generate the compiled representation of the JXPath
  
  
  
  1.2       +4 -3      cocoon-2.1/src/java/org/apache/cocoon/transformation/JPathTransformer.java
  
  Index: JPathTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/transformation/JPathTransformer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JPathTransformer.java	9 Mar 2003 00:09:39 -0000	1.1
  +++ JPathTransformer.java	7 May 2003 04:36:33 -0000	1.2
  @@ -54,6 +54,7 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.flow.WebContinuation;
  +import org.apache.cocoon.components.flow.Flow;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.commons.jxpath.JXPathContext;
  @@ -160,8 +161,8 @@
           super.setup(resolver, objectModel, src, parameters);
   
           // setup the jpath transformer for this thread
  -        Object bean = ((Environment)resolver).getAttribute("bean-dict");
  -        m_kont = (WebContinuation)((Environment)resolver).getAttribute("kont");
  +        Object bean = Flow.getContextObject(objectModel);
  +        m_kont = Flow.getWebContinuation(objectModel);
           m_jxpathContext = JXPathContext.newContext(bean);
       }
   
  
  
  
  1.7       +6 -5      cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/FlowVelocityGenerator.java
  
  Index: FlowVelocityGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/FlowVelocityGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FlowVelocityGenerator.java	22 Apr 2003 20:03:42 -0000	1.6
  +++ FlowVelocityGenerator.java	7 May 2003 04:36:33 -0000	1.7
  @@ -61,6 +61,7 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  +import org.apache.cocoon.components.flow.Flow;
   import org.apache.cocoon.components.flow.WebContinuation;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.ObjectModelHelper;
  @@ -868,11 +869,11 @@
           this.resolverContext.put(CONTEXT_SOURCE_CACHE_KEY, new HashMap());
   
           // FIXME: Initialize the Velocity context. Use objectModel to pass these
  -        final Object bean = ((Environment) resolver).getAttribute("bean-dict");
  +        final Object bean = Flow.getContextObject(objectModel);
           if (bean != null) {
  -            final WebContinuation kont =
  -                (WebContinuation) ((Environment) resolver).getAttribute("kont");
  -            
  +
  +            final WebContinuation kont = Flow.getWebContinuation(objectModel);
  +
               // Hack? I use JXPath to determine the properties of the bean object
               final JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass());
               DynamicPropertyHandler h = null;
  
  
  
  1.14      +4 -4      cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JXFormsGenerator.java
  
  Index: JXFormsGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JXFormsGenerator.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JXFormsGenerator.java	4 May 2003 20:24:47 -0000	1.13
  +++ JXFormsGenerator.java	7 May 2003 04:36:33 -0000	1.14
  @@ -35,7 +35,7 @@
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
    APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  -INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
    DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
    OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
    ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  @@ -60,6 +60,7 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.flow.WebContinuation;
  +import org.apache.cocoon.components.flow.Flow;
   import org.apache.cocoon.components.jxforms.validation.Violation;
   import org.apache.cocoon.components.jxforms.xmlform.Form;
   import org.apache.cocoon.components.source.SourceUtil;
  @@ -1193,9 +1194,8 @@
                   }
               }
           }
  -        // FIX ME: When we decide proper way to pass "bean" and "kont"
  -        bean = ((Environment)resolver).getAttribute("bean-dict");
  -        kont = (WebContinuation)((Environment)resolver).getAttribute("kont");
  +        bean = Flow.getContextObject(objectModel);
  +        kont = Flow.getWebContinuation(objectModel);
           this.objectModel = objectModel;
       }
   
  
  
  
  1.8       +172 -106  cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JXTemplateGenerator.java
  
  Index: JXTemplateGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JXTemplateGenerator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JXTemplateGenerator.java	6 May 2003 12:22:12 -0000	1.7
  +++ JXTemplateGenerator.java	7 May 2003 04:36:34 -0000	1.8
  @@ -67,6 +67,8 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.flow.WebContinuation;
  +import org.apache.cocoon.components.flow.Flow;
  +import org.apache.cocoon.components.flow.javascript.JavaScriptFlow;
   import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.ObjectModelHelper;
  @@ -224,7 +226,7 @@
    *   &lt;/c:forEach&gt;
    * &lt;/c:macro&gt;
    * </pre></p>
  - * <p>The <code>parameter</code> tags in the macro definition define formal parameters, which are replaced with the actual attribute values of the tag when it is used. The content of the tag is also available as a special variable <code>${body}</code>.</p><p>Assuming you had this code in your flowscript:</p>
  + * <p>The <code>parameter</code> tags in the macro definition define formal parameters, which are replaced with the actual attribute values of the tag when it is used. The content of the tag is also available as a special variable <code>${content}</code>.</p><p>Assuming you had this code in your flowscript:</p>
    *    <code>var greatlakes = ["Superior", "Michigan", "Huron", "Erie", "Ontario"];</code></p><p><code> sendPage(uri, {greatlakes: greatlakes});</code>
    * </p><p>and a template like this:</p><p><pre>
    * &lt;table&gt;
  @@ -683,8 +685,8 @@
        * (contained in #{}) 
        */
   
  -    private static Object compileExpr(String expr, String errorPrefix, 
  -                                      Locator location) 
  +    private static Expression compileExpr(String expr, String errorPrefix, 
  +                                          Locator location) 
           throws SAXParseException {
           try {
               return compileExpr(expr);
  @@ -697,7 +699,7 @@
           }
       }
   
  -    private static Object compileExpr(String inStr) throws Exception {
  +    private static Expression compileExpr(String inStr) throws Exception {
           try {
               if (inStr == null) return null;
               StringReader in = new StringReader(inStr.trim());
  @@ -732,47 +734,51 @@
                       }
                       // hack: invalid expression?
                       // just return the original and swallow exception
  -                    return inStr;
  +                    return new Expression(inStr, null);
                   }
               }
           } catch (IOException ignored) {
               ignored.printStackTrace();
           }
  -        return inStr;
  +        return new Expression(inStr, null);
       }
       // Compile an integer expression (returns either a Compiled Expression
       // or an Integer literal)
  -    private static Object compileInt(String val, String msg, Locator location) 
  +    private static Expression compileInt(String val, String msg, Locator location) 
           throws SAXException {
  -        Object res = compileExpr(val, msg, location);
  -        if (res instanceof String) {
  -            return Integer.valueOf(val);
  +        Expression res = compileExpr(val, msg, location);
  +        if (res == null) return null;
  +        if (res.compiledExpression != null) {
  +            res.compiledExpression = Integer.valueOf(res.raw);
           }
           return res;
       }
   
  -    private static Object compile(final String variable, boolean xpath) 
  +    private static Expression compile(final String variable, boolean xpath) 
           throws Exception {
  +        Object compiled;
           if (xpath) {
  -            return JXPathContext.compile(variable);
  +            compiled = JXPathContext.compile(variable);
           } else {
  -            return ExpressionFactory.createExpression(variable);
  +            compiled = ExpressionFactory.createExpression(variable);
           }
  +        return new Expression(variable, compiled);
       }
   
  -    private Object getValue(Object expr, JexlContext jexlContext,
  +    private Object getValue(Expression expr, JexlContext jexlContext,
                               JXPathContext jxpathContext) 
           throws Exception {
  +        Object compiled = expr.compiledExpression;
           try {
  -            if (expr instanceof CompiledExpression) {
  -                CompiledExpression e = (CompiledExpression)expr;
  +            if (compiled instanceof CompiledExpression) {
  +                CompiledExpression e = (CompiledExpression)compiled;
                   return e.getValue(jxpathContext);
  -            } else if (expr instanceof org.apache.commons.jexl.Expression) {
  +            } else if (compiled instanceof org.apache.commons.jexl.Expression) {
                   org.apache.commons.jexl.Expression e = 
  -                    (org.apache.commons.jexl.Expression)expr;
  +                    (org.apache.commons.jexl.Expression)compiled;
                   return e.evaluate(jexlContext);
               }
  -            return expr;
  +            return compiled;
           } catch (InvocationTargetException e) {
               Throwable t = e.getTargetException();
               if (t instanceof Exception) {
  @@ -782,7 +788,7 @@
           }
       }
   
  -    private int getIntValue(Object expr, JexlContext jexlContext,
  +    private int getIntValue(Expression expr, JexlContext jexlContext,
                               JXPathContext jxpathContext) 
           throws Exception {
           Object res = getValue(expr, jexlContext, jxpathContext);
  @@ -793,19 +799,20 @@
       }
   
       // Hack: try to prevent JXPath from converting result to a String
  -    private Object getNode(Object expr, JexlContext jexlContext,
  +    private Object getNode(Expression expr, JexlContext jexlContext,
                              JXPathContext jxpathContext) 
           throws Exception {
           try {
  -            if (expr instanceof CompiledExpression) {
  -                CompiledExpression e = (CompiledExpression)expr;
  -                return e.getPointer(jxpathContext, "").getNode();
  -            } else if (expr instanceof org.apache.commons.jexl.Expression) {
  +            Object compiled = expr.compiledExpression;
  +            if (compiled instanceof CompiledExpression) {
  +                CompiledExpression e = (CompiledExpression)compiled;
  +                return e.getPointer(jxpathContext, expr.raw).getNode();
  +            } else if (compiled instanceof org.apache.commons.jexl.Expression) {
                   org.apache.commons.jexl.Expression e = 
  -                    (org.apache.commons.jexl.Expression)expr;
  +                    (org.apache.commons.jexl.Expression)compiled;
                   return e.evaluate(jexlContext);
               }
  -            return expr;
  +            return compiled;
           } catch (InvocationTargetException e) {
               Throwable t = e.getTargetException();
               if (t instanceof Exception) {
  @@ -880,7 +887,8 @@
                                                                   location,
                                                                   exc);
                                   }
  -                                substitutions.add(compiledExpression);
  +                                substitutions.add(new Expression(str,
  +                                                                 compiledExpression));
                                   buf.setLength(0);
                                   inExpr = false;
                               } else {
  @@ -1043,10 +1051,12 @@
       }
       
       static class Expression extends Subst {
  -        Expression(Object expr) {
  +        Expression(String raw, Object expr) {
  +            this.raw = raw;
               this.compiledExpression = expr;
           }
  -        final Object compiledExpression;
  +        String raw;
  +        Object compiledExpression;
       }
   
       static class SubstituteAttribute extends AttributeEvent {
  @@ -1097,7 +1107,7 @@
                                       }
                                   } else if (c == '}') {
                                       String str = buf.toString();
  -                                    Object compiledExpression;
  +                                    Expression compiledExpression;
                                       try {
                                           compiledExpression =
                                               compile(str, xpath);
  @@ -1111,7 +1121,7 @@
                                                                       null);
                                           
                                       } 
  -                                    substEvents.add(new Expression(compiledExpression));
  +                                    substEvents.add(compiledExpression);
                                       buf.setLength(0);
                                       inExpr = false;
                                   } else {
  @@ -1279,8 +1289,8 @@
   
       static class StartForEach extends StartInstruction {
           StartForEach(StartElement raw,
  -                     Object items, String var,
  -                     Object begin, Object end, Object step) {
  +                     Expression items, String var,
  +                     Expression begin, Expression end, Expression step) {
               super(raw);
               this.items = items;
               this.var = var;
  @@ -1288,19 +1298,19 @@
               this.end = end;
               this.step = step;
           }
  -        final Object items;
  +        final Expression items;
           final String var;
  -        final Object begin;
  -        final Object end;
  -        final Object step;
  +        final Expression begin;
  +        final Expression end;
  +        final Expression step;
       }
       
       static class StartIf extends StartInstruction {
  -        StartIf(StartElement raw, Object test) {
  +        StartIf(StartElement raw, Expression test) {
               super(raw);
               this.test = test;
           }
  -        final Object test;
  +        final Expression test;
       }
   
   
  @@ -1313,11 +1323,11 @@
       }
   
       static class StartWhen extends StartInstruction {
  -        StartWhen(StartElement raw, Object test) {
  +        StartWhen(StartElement raw, Expression test) {
               super(raw);
               this.test = test;
           }
  -        final Object test;
  +        final Expression test;
           StartWhen nextChoice;
       }
   
  @@ -1328,22 +1338,22 @@
       }
   
       static class StartOut extends StartInstruction {
  -        StartOut(StartElement raw, Object expr) {
  +        StartOut(StartElement raw, Expression expr) {
               super(raw);
               this.compiledExpression = expr;
           }
  -        final Object compiledExpression;
  +        final Expression compiledExpression;
       }
   
       static class StartImport extends StartInstruction {
           StartImport(StartElement raw, AttributeEvent uri, 
  -                    Object select) {
  +                    Expression select) {
               super(raw);
               this.uri = uri;
               this.select = select;
           }
           final AttributeEvent uri;
  -        final Object select;
  +        final Expression select;
       }
   
       static class StartTemplate extends StartInstruction {
  @@ -1379,10 +1389,20 @@
                       if (prev != null) {
                           throw new SAXParseException("duplicate parameter: \""+startParam.name +"\"", location, null);
                       }
  +                    e = startParam.endInstruction.next;
                   } else if (e instanceof IgnorableWhitespace) {
  -                } else if (e instanceof EndInstruction) {
                   } else if (e instanceof Characters) {
  -                    // fix me: check for whitespace
  +                    // check for whitespace
  +                    char[] ch = ((TextEvent)e).raw;
  +                    for (int i = 0; i < ch.length; i++) {
  +                        if (!Character.isWhitespace(ch[i])) {
  +                            if (params) {
  +                                params = false;
  +                                body = e;
  +                            }
  +                            break;
  +                        }
  +                    }
                   } else {
                       if (params) {
                           params = false;
  @@ -1411,13 +1431,13 @@
       }
   
       static class StartSet extends StartInstruction {
  -        StartSet(StartElement raw, String var, Object value) {
  +        StartSet(StartElement raw, String var, Expression value) {
               super(raw);
               this.var = var;
               this.value = value;
           }
           final String var;
  -        final Object value;
  +        final Expression value;
       }
   
       static class Parser implements ContentHandler, LexicalHandler {
  @@ -1572,13 +1592,13 @@
                   if (localName.equals(FOR_EACH)) {
                       String items = attrs.getValue("items");
                       String select = attrs.getValue("select");
  -                    Object begin = compileInt(attrs.getValue("begin"),
  -                                              FOR_EACH, locator);
  -                    Object end = compileInt(attrs.getValue("end"),
  -                                            FOR_EACH, locator);
  -                    Object step = compileInt(attrs.getValue("step"),
  -                                             FOR_EACH,
  -                                             locator);
  +                    Expression begin = compileInt(attrs.getValue("begin"),
  +                                                  FOR_EACH, locator);
  +                    Expression end = compileInt(attrs.getValue("end"),
  +                                                FOR_EACH, locator);
  +                    Expression step = compileInt(attrs.getValue("step"),
  +                                                 FOR_EACH,
  +                                                 locator);
                       String var = attrs.getValue("var");
                       if (items == null) {
                           if (select == null && (begin == null || end == null)) {
  @@ -1587,7 +1607,7 @@
                       } else if (select != null) {
                           throw new SAXParseException("forEach: only one of \"select\" or \"items\" may be specified", locator, null);
                       }
  -                    Object expr;
  +                    Expression expr;
                       expr = compileExpr(items == null ? select : items,
                                          null, locator);
                       StartForEach startForEach = 
  @@ -1606,7 +1626,7 @@
                       if (test == null) {
                           throw new SAXParseException("when: \"test\" is required", locator, null);
                       }
  -                    Object expr;
  +                    Expression expr;
                       expr = compileExpr(test, "when: \"test\": ", locator);
                       StartWhen startWhen = new StartWhen(startElement, expr);
                       newEvent = startWhen;
  @@ -1615,7 +1635,7 @@
                       if (value == null) {
                           throw new SAXParseException("out: \"value\" is required", locator, null);
                       }
  -                    Object expr = compileExpr(value, 
  +                    Expression expr = compileExpr(value, 
                                                 "out: \"value\": ", 
                                                 locator);
                       newEvent = new StartOut(startElement, expr);
  @@ -1632,7 +1652,7 @@
                       if (test == null) {
                           throw new SAXParseException("if: \"test\" is required", locator, null);
                       }
  -                    Object expr = 
  +                    Expression expr = 
                           compileExpr(test, "if: \"test\": ", locator);
                       StartIf startIf = 
                           new StartIf(startElement, expr);
  @@ -1677,7 +1697,7 @@
                   } else if (localName.equals(SET)) {
                       String var = attrs.getValue("var");
                       String value = attrs.getValue("value");
  -                    Object valueExpr = null;
  +                    Expression valueExpr = null;
                       if (value != null) {
                           valueExpr = 
                               compileExpr(value, "set: \"value\":",
  @@ -1702,7 +1722,7 @@
                       // If "context" is present then its value will be used
                       // as the context object in the imported template
                       String select = attrs.getValue("context");
  -                    Object expr = null;
  +                    Expression expr = null;
                       if (select != null) {
                           expr = 
                               compileExpr(select, "import: \"context\": ",
  @@ -1864,15 +1884,14 @@
                   }
               }
           }
  -        // FIX ME: When we decide proper way to pass "bean" and "kont"
  -        Object bean = ((Environment)resolver).getAttribute("bean-dict");
  -        WebContinuation kont =
  -            (WebContinuation)((Environment)resolver).getAttribute("kont");
  +        Object bean = Flow.getContextObject(objectModel);
  +        WebContinuation kont = Flow.getWebContinuation(objectModel);
           setContexts(bean, kont,
                       ObjectModelHelper.getRequest(objectModel),
                       ObjectModelHelper.getResponse(objectModel),
                       ObjectModelHelper.getContext(objectModel),
  -                    parameters);
  +                    parameters,
  +                    objectModel);
           definitions = new HashMap();
       }
       
  @@ -1918,7 +1937,8 @@
                                Request request,
                                Response response,
                                org.apache.cocoon.environment.Context app,
  -                             Parameters parameters) {
  +                             Parameters parameters,
  +                             Map objectModel) {
           if (variables == null) {
               variables = new MyVariables(contextObject,
                                           kont,
  @@ -1942,6 +1962,12 @@
           if (contextObject != null) {
               map.put("flowContext", contextObject);
               map.put("continuation", kont);
  +            // Here I use Rhino's live-connect objects to allow Jexl to call 
  +            // java constructors
  +            Object javaPkg = JavaScriptFlow.getJavaPackage(objectModel);
  +            Object pkgs = JavaScriptFlow.getPackages(objectModel);
  +            map.put("java", javaPkg);
  +            map.put("Packages", pkgs);
           }
           map.put("request", request);
           map.put("response", response);
  @@ -1993,7 +2019,7 @@
               if (subst instanceof char[]) {
                   chars = (char[])subst;
               } else {
  -                Object expr = subst;
  +                Expression expr = (Expression)subst;
                   try {
                       Object val = getValue(expr, jexlContext, jxpathContext);
                       if (val != null) {
  @@ -2115,6 +2141,23 @@
                   parser.getStartEvent(), null);
       }
   
  +    private void call(Locator location,
  +                      String messagePrefix,
  +                      final XMLConsumer consumer,
  +                      MyJexlContext jexlContext,
  +                      JXPathContext jxpathContext,
  +                      Event startEvent, Event endEvent) 
  +        throws SAXException {
  +        try {
  +            execute(consumer, jexlContext,
  +                    jxpathContext, startEvent, endEvent);
  +        } catch (SAXParseException exc) {
  +            throw new SAXParseException(messagePrefix +": " +exc.getMessage(),
  +                                        location, 
  +                                        exc);
  +        }
  +    }
  +
       private void execute(final XMLConsumer consumer,
                            MyJexlContext jexlContext,
                            JXPathContext jxpathContext,
  @@ -2132,7 +2175,7 @@
                       if (subst instanceof char[]) {
                           chars = (char[])subst;
                       } else {
  -                        Object expr = subst;
  +                        Expression expr = (Expression)subst;
                           try {
                               Object val = 
                                   getNode(expr, jexlContext, jxpathContext);
  @@ -2248,30 +2291,41 @@
                   try {
                       if (items == null) {
                           iter = NULL_ITER;
  -                    } else if (items instanceof CompiledExpression) {
  -                        CompiledExpression compiledExpression = 
  -                            (CompiledExpression)items;
  -                        iter = 
  -                            compiledExpression.iteratePointers(jxpathContext);
  -                        xpath = true;
  -                    } else if (items instanceof org.apache.commons.jexl.Expression) {
  -                        org.apache.commons.jexl.Expression e = 
  -                            (org.apache.commons.jexl.Expression)items;
  -                        Object result = e.evaluate(jexlContext);
  -                        if (result != null) {
  -                            iter =
  -                                org.apache.commons.jexl.util.Introspector.getUberspect().getIterator(result, new Info(ev.location.getSystemId(),
  -                                                                                                                      ev.location.getLineNumber(),
  -                                                                                                                      ev.location.getColumnNumber()));
  -                            
  -                        }
  -                        if (iter == null) {
  -                            iter = EMPTY_ITER;
  -                        }
                       } else {
  -                        // literal value
  -                        iter = new Iterator() {
  +                        Expression expr = (Expression)items;
  +                        if (expr.compiledExpression instanceof CompiledExpression) {
  +                            CompiledExpression compiledExpression = 
  +                                (CompiledExpression)expr.compiledExpression;
  +                            Object val = 
  +                                compiledExpression.getPointer(jxpathContext,
  +                                                              expr.raw).getNode();
  +                            // Hack: workaround for JXPath bug
  +                            if (val instanceof NativeArray) {
  +                                iter = 
  +                                    new JSIntrospector.NativeArrayIterator((NativeArray)val);
  +                            } else {
  +                                iter = 
  +                                    compiledExpression.iteratePointers(jxpathContext);
  +                                xpath = true;
  +                            }
  +                        } else if (expr.compiledExpression instanceof org.apache.commons.jexl.Expression) {
  +                            org.apache.commons.jexl.Expression e = 
  +                                (org.apache.commons.jexl.Expression)expr.compiledExpression;
  +                            Object result = e.evaluate(jexlContext);
  +                            if (result != null) {
  +                                iter =
  +                                    org.apache.commons.jexl.util.Introspector.getUberspect().getIterator(result, new Info(ev.location.getSystemId(),
  +                                                                                                                          ev.location.getLineNumber(),
  +                                                                                                                          ev.location.getColumnNumber()));
                                   
  +                            }
  +                            if (iter == null) {
  +                                iter = EMPTY_ITER;
  +                            }
  +                        } else {
  +                            // literal value
  +                            iter = new Iterator() {
  +                                    
                                   Object val = items;
                                   
                                   public boolean hasNext() {
  @@ -2287,6 +2341,7 @@
                                   public void remove() {
                                   }
                               };
  +                        }
                       }
                       begin = startForEach.begin == null ? 0 :
                           getIntValue(startForEach.begin, jexlContext, jxpathContext);
  @@ -2407,7 +2462,14 @@
                       builder.endDocument();
                       Node node = builder.getDocument().getDocumentElement();
                       NodeList nodeList = node.getChildNodes();
  -                    value = nodeList;
  +                    int len = nodeList.getLength();
  +                    // JXPath doesn't handle NodeList, so convert
  +                    // it to an array
  +                    Node[] nodeArr = new Node[len];
  +                    for (int i = 0; i < len; i++) {
  +                        nodeArr[i] = nodeList.item(i);
  +                    }
  +                    value = nodeArr;
                   }
                   jxpathContext.getVariables().declareVariable(startSet.var, 
                                                                value);
  @@ -2443,9 +2505,9 @@
                                   Object val;
                                   try {
                                       val = 
  -                                        getValue(expr.compiledExpression,
  -                                                 jexlContext,
  -                                                 jxpathContext);
  +                                        getNode(expr,
  +                                                jexlContext,
  +                                                jxpathContext);
                                   } catch (Exception e) {
                                       throw new SAXParseException(e.getMessage(),
                                                                   ev.location,
  @@ -2468,7 +2530,7 @@
                                           Object val;
                                           try {
                                               val = 
  -                                                getValue(expr.compiledExpression,
  +                                                getValue(expr,
                                                            jexlContext,
                                                            jxpathContext);
                                           } catch (Exception e) {
  @@ -2509,13 +2571,16 @@
                       vars.localVariables = new HashMap();
                       MyJexlContext localJexlContext = 
                           new MyJexlContext(globalJexlContext);
  +                    // JXPath doesn't handle NodeList, so convert it to
  +                    // an array
                       NodeList children = node.getChildNodes();
                       int len = children.getLength();
                       Node[] arr = new Node[len];
                       for (int ii = 0; ii < len; ii++) {
                           arr[ii] = children.item(ii);
                       }
  -                    localJexlContext.put("body", arr);
  +                    localJexlContext.put("content", arr);
  +                    vars.localVariables.put("content", arr);
                       Iterator iter = def.parameters.entrySet().iterator();
                       while (iter.hasNext()) {
                           Map.Entry e = (Map.Entry)iter.next();
  @@ -2531,12 +2596,13 @@
                           vars.localVariables.put(key, val);
                       }
                       JXPathContext localJXPathContext =
  -                        jxpathContextFactory.newContext(jxpathContext, 
  -                                                        arr);
  +                        jxpathContextFactory.newContext(null, arr);
                       localJXPathContext.setVariables(vars);
  -                    execute(consumer, 
  -                            localJexlContext, localJXPathContext,
  -                            def.body, def.endInstruction);
  +                    call(ev.location,
  +                         startElement.localName,
  +                         consumer, 
  +                         localJexlContext, localJXPathContext,
  +                         def.body, def.endInstruction);
                       vars.localVariables = saveLocals;
                       ev = startElement.endElement.next;
                       continue;
  @@ -2570,7 +2636,7 @@
                                   Object val;
                                   try {
                                       val = 
  -                                        getValue(expr.compiledExpression,
  +                                        getValue(expr,
                                                    jexlContext,
                                                    jxpathContext);
                                   } catch (Exception e) {
  @@ -2699,7 +2765,7 @@
                               Object val;
                               try {
                                   val = 
  -                                    getValue(expr.compiledExpression,
  +                                    getValue(expr,
                                                jexlContext,
                                                jxpathContext);
                               } catch (Exception exc) {
  
  
  
  1.5       +3 -4      cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/TraxGenerator.java
  
  Index: TraxGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/TraxGenerator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TraxGenerator.java	4 May 2003 20:24:47 -0000	1.4
  +++ TraxGenerator.java	7 May 2003 04:36:34 -0000	1.5
  @@ -63,6 +63,7 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.flow.WebContinuation;
  +import org.apache.cocoon.components.flow.Flow;
   import org.apache.cocoon.components.jxdom.DocumentAdapter;
   import org.apache.cocoon.environment.Context;
   import org.apache.cocoon.environment.Environment;
  @@ -89,10 +90,8 @@
                         String src, Parameters parameters)
           throws ProcessingException, SAXException, IOException {
           super.setup(resolver, objectModel, src, parameters);
  -        // FIX ME: When we decide proper way to pass "bean" and "kont"
  -        Object bean = ((Environment)resolver).getAttribute("bean-dict");
  -        WebContinuation kont = 
  -            (WebContinuation)((Environment)resolver).getAttribute("kont");
  +        Object bean = Flow.getContextObject(objectModel);
  +        WebContinuation kont = Flow.getWebContinuation(objectModel);
           Map map = new HashMap();
           Request request = ObjectModelHelper.getRequest(objectModel);
           Response response = ObjectModelHelper.getResponse(objectModel);