You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by st...@apache.org on 2003/04/05 01:08:13 UTC

cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript system.js JSCocoon.java

stefano     2003/04/04 15:08:13

  Modified:    src/java/org/apache/cocoon/components/flow/javascript
                        system.js JSCocoon.java
  Log:
  added the ability to send a redirect to the browser directly from the flowscript. You could do this before since you had direct access to the Environment, but it makes it more evident if it's added directly to the FOM. Note that the method doesn't create sessions, you have to do it by hand if you really need one. The method is inherently stateless.
  
  Revision  Changes    Path
  1.5       +9 -1      cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/system.js
  
  Index: system.js
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/system.js,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- system.js	25 Mar 2003 14:25:18 -0000	1.4
  +++ system.js	4 Apr 2003 23:08:13 -0000	1.5
  @@ -63,6 +63,14 @@
     sendPage("invalidContinuation", {"ident" : id});
   }
   
  +// Redirect Support
  +//
  +// redirect to the given URI
  +function redirect(uri)
  +{
  +  cocoon.redirect(uri);
  +}
  +
   // Action Support
   //
   // call an action from JS
  
  
  
  1.9       +16 -1     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JSCocoon.java	20 Mar 2003 04:18:51 -0000	1.8
  +++ JSCocoon.java	4 Apr 2003 23:08:13 -0000	1.9
  @@ -256,6 +256,21 @@
       }
   
       /**
  +     * Send a client-side redirect to the browser.
  +     *
  +     * @param uri The URI to which the browser should be redirected to.
  +     */
  +    public void jsFunction_redirect(String uri)
  +        throws JavaScriptException
  +    {
  +        try {
  +            environment.redirect(false,uri);
  +        } catch (Exception e) {
  +            throw new JavaScriptException(e);
  +        }
  +    }
  +
  +    /**
          Set the Scope object in the session object of the current
          user. This effectively means that at the next invocation from the
          sitemap of a JavaScript function (using the <map:call