Author: fmeschbe
Date: Mon Jan 26 11:49:11 2009
New Revision: 737675

URL: http://svn.apache.org/viewvc?rev=737675&view=rev
Log:
SLING-704 Add convenience methods: forward(String) and forward(String, String)

Modified:
    
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/scripting/SlingScriptHelper.java
    
incubator/sling/trunk/scripting/core/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java

Modified: 
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/scripting/SlingScriptHelper.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/scripting/SlingScriptHelper.java?rev=737675&r1=737674&r2=737675&view=diff
==============================================================================
--- 
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/scripting/SlingScriptHelper.java
 (original)
+++ 
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/scripting/SlingScriptHelper.java
 Mon Jan 26 11:49:11 2009
@@ -118,6 +118,48 @@
     void include(String path, RequestDispatcherOptions options);
 
     /**
+     * Same as {...@link #forward(String,RequestDispatcherOptions)}, but using
+     * empty options.
+     * 
+     * @throws SlingIOException Wrapping a <code>IOException</code> thrown
+     *             while handling the forward.
+     * @throws SlingServletException Wrapping a <code>ServletException</code>
+     *             thrown while handling the forward.
+     */
+    void forward(String path);
+
+    /**
+     * Helper method to forward the request to a Servlet or script for the 
given
+     * <code>path</code> and <code>requestDispatcherOptions</code>. This method
+     * is intended to be implemented as follows:
+     * 
+     * <pre>
+     * RequestDispatcher dispatcher = getRequest().getRequestDispatcher(path,
+     *     &quot;option:xyz&quot;);
+     * if (dispatcher != null) {
+     *     dispatcher.forward(getRequest(), getResponse());
+     * }
+     * </pre>
+     * 
+     * <p>
+     * This method creates a <code>RequestDispatcherOptions</code> object by
+     * calling the
+     * {...@link RequestDispatcherOptions#RequestDispatcherOptions(String)}
+     * constructor.
+     * 
+     * @param path The path to the resource to forward to.
+     * @param requestDispatcherOptions influence the rendering of the forwarded
+     *            Resource
+     * @throws SlingIOException Wrapping a <code>IOException</code> thrown
+     *             while handling the forward.
+     * @throws SlingServletException Wrapping a <code>ServletException</code>
+     *             thrown while handling the forward.
+     * @see RequestDispatcherOptions#RequestDispatcherOptions(String)
+     * @see #forward(String, RequestDispatcherOptions)
+     */
+    void forward(String path, String requestDispatcherOptions);
+
+    /**
      * Helper method to forward the request to a Servlet or script for the 
given
      * <code>path</code> and <code>options</code>. This method is intended
      * to be implemented as follows:

Modified: 
incubator/sling/trunk/scripting/core/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/core/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java?rev=737675&r1=737674&r2=737675&view=diff
==============================================================================
--- 
incubator/sling/trunk/scripting/core/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java
 (original)
+++ 
incubator/sling/trunk/scripting/core/src/main/java/org/apache/sling/scripting/core/ScriptHelper.java
 Mon Jan 26 11:49:11 2009
@@ -131,6 +131,16 @@
         }
     }
     
+    /** Forward the request to another resource, using no options */
+    public void forward(String path) {
+        forward(path, (RequestDispatcherOptions) null);
+    }
+
+    /** Forward the request to another resource, using specified options */
+    public void forward(String path, String options) {
+        forward(path, new RequestDispatcherOptions(options));
+    }
+
     /** Forward the request to another resource, using specified options */
     public void forward(String path, RequestDispatcherOptions options) {
         final RequestDispatcher dispatcher = getRequest().getRequestDispatcher(


Reply via email to