You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by am...@apache.org on 2017/10/04 19:59:09 UTC

[struts-site] branch master updated: fix more result pages

This is an automated email from the ASF dual-hosted git repository.

amashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts-site.git


The following commit(s) were added to refs/heads/master by this push:
     new cb4690f  fix more result pages
cb4690f is described below

commit cb4690ffa36814ac3096ceb9cf7d0478c4bf1e56
Author: Aleksandr Mashchenko <am...@apache.org>
AuthorDate: Wed Oct 4 22:58:31 2017 +0300

    fix more result pages
---
 source/core-developers/httpheader-result.md      |   2 +-
 source/core-developers/redirect-action-result.md | 103 +++++++++++++++-------
 source/core-developers/redirect-result.md        |  32 ++++---
 source/core-developers/stream-result.md          | 106 +++++------------------
 4 files changed, 111 insertions(+), 132 deletions(-)

diff --git a/source/core-developers/httpheader-result.md b/source/core-developers/httpheader-result.md
index 63c52e7..0fda09d 100644
--- a/source/core-developers/httpheader-result.md
+++ b/source/core-developers/httpheader-result.md
@@ -12,7 +12,7 @@ A custom Result type for setting HTTP headers and status by optionally evaluatin
 
 - `status` - the http servlet response status code that should be set on a response.
 
-- `parse` - true by default. If set to false, the headers param will not be parsed for Ognl expressions.
+- `parse` - true by default. If set to false, the headers param will not be parsed for OGNL expressions.
 
 - `headers` - header values.
 
diff --git a/source/core-developers/redirect-action-result.md b/source/core-developers/redirect-action-result.md
index d661b3a..b951575 100644
--- a/source/core-developers/redirect-action-result.md
+++ b/source/core-developers/redirect-action-result.md
@@ -5,47 +5,84 @@ title: Redirect Action Result
 
 # Redirect Action Result
 
+This result uses the `ActionMapper` provided by the `ActionMapperFactory` to redirect the browser to a URL that invokes the specified action and (optional) namespace. This is better than the `ServletRedirectResult` because it does not require you to encode the URL patterns processed by the `ActionMapper` in to your struts.xml configuration files. This means you can change your URL patterns at any point and your application will still work. It is strongly recommended that if you are redir [...]
 
-
-{% snippet id=description|javadoc=true|url=org.apache.struts2.result.ServletActionRedirectResult %}
-
+See examples below for an example of how request parameters could be passed in.
 
 See [ActionMapper](action-mapper.html) for more details
 
-| 
-
-####Parameters####
-
-
-
-{% snippet id=params|javadoc=true|url=org.apache.struts2.result.ServletActionRedirectResult %}
-
-####Examples####
-
 
-
-{% snippet id=example|lang=xml|javadoc=true|url=org.apache.struts2.result.ServletActionRedirectResult %}
-
-
-
-~~~~~~~
+### Parameters
+
+- `actionName` (default) - The name of the action that will be redirected to.
+- `namespace` - Used to determine which namespace the action is in that we're redirecting to. If namespace is null, the default will be the current namespace.
+- `suppressEmptyParameters` - Optional boolean (defaults to false) that can prevent parameters with no values from being included in the redirect URL.
+- `parse` - Boolean, true by default. If set to false, the actionName param will not be parsed for OGNL expressions.
+- `anchor` - Optional. Also known as "fragment" or colloquially as "hash". You can specify an anchor for a result.
+
+### Examples
+
+```
+<package name="public" extends="struts-default">
+    <action name="login" class="...">
+        <!-- Redirect to another namespace -->
+        <result type="redirectAction">
+            <param name="actionName">dashboard</param>
+            <param name="namespace">/secure</param>
+        </result>
+    </action>
+</package>
+ 
+<package name="secure" extends="struts-default" namespace="/secure">
+    <-- Redirect to an action in the same namespace -->
+    <action name="dashboard" class="...">
+        <result>dashboard.jsp</result>
+        <result name="error" type="redirectAction">error</result>
+    </action>
+ 
+    <action name="error" class="...">
+        <result>error.jsp</result>
+    </action>
+</package>
+ 
+<package name="passingRequestParameters" extends="struts-default" namespace="/passingRequestParameters">
+   <!-- Pass parameters (reportType, width and height) -->
+   <!--
+   The redirectAction url generated will be :
+   /genReport/generateReport.action?reportType=pie&amp;width=100&amp;height=100#summary
+   -->
+   <action name="gatherReportInfo" class="...">
+      <result name="showReportResult" type="redirectAction">
+         <param name="actionName">generateReport</param>
+         <param name="namespace">/genReport</param>
+         <param name="reportType">pie</param>
+         <param name="width">100</param>
+         <param name="height">100</param>
+         <param name="empty"></param>
+         <param name="suppressEmptyParameters">true</param>
+         <param name="anchor">summary</param>
+      </result>
+   </action>
+</package>
+```
+
+```
 <!--
-	Example of "anchor" param usage in conjunction with "redirectAction" result-type.
-
-	Generated URL: /displayReport.action#SUMMARY
+    Example of "anchor" param usage in conjunction with "redirectAction" result-type.
+ 
+    Generated URL: /displayReport.action#SUMMARY
 -->
-
+ 
 <action name="displayReport">
-	<result>/jsp/displayReport.jsp</result>
+    <result>/jsp/displayReport.jsp</result>
 </action>
-
+ 
 <action name="financeReport" class="com.mycompany.reports.FinanceReportAction"> 
-	<result name="input">/jsp/index.jsp</result>            
-	<result name="success" type="redirectAction">
-		<param name="actionName">displayReport</param>
-		<param name="parse">false</param>
-		<param name="anchor">SUMMARY</param>
-	</result>
+    <result name="input">/jsp/index.jsp</result>            
+    <result name="success" type="redirectAction">
+        <param name="actionName">displayReport</param>
+        <param name="parse">false</param>
+        <param name="anchor">SUMMARY</param>
+    </result>
 </action>
-
-~~~~~~~
+```
diff --git a/source/core-developers/redirect-result.md b/source/core-developers/redirect-result.md
index b79469d..9461e8e 100644
--- a/source/core-developers/redirect-result.md
+++ b/source/core-developers/redirect-result.md
@@ -5,25 +5,34 @@ title: Redirect Result
 
 # Redirect Result
 
+Calls the `{@link HttpServletResponse#sendRedirect(String) sendRedirect}` method to the location specified. The response is told to redirect the browser to the specified location (a new request from the client). The consequence of doing this means that the action (action instance, action errors, field errors, etc) that was just executed is lost and no longer available. This is because actions are built on a single-thread model. The only way to pass data is through the session or with web [...]
 
+### Parameters
 
-{% snippet id=description|javadoc=true|url=org.apache.struts2.result.ServletRedirectResult %}
+- `location` (default) - the location to go to after execution.
 
-####Parameters####
+- `parse` - true by default. If set to false, the location param will not be parsed for OGNL expressions.
 
+- `anchor` - Optional. Also known as "fragment" or colloquially as "hash". You can specify an anchor for a result.
 
+This result follows the same rules from StrutsResultSupport. 
 
-{% snippet id=params|javadoc=true|url=org.apache.struts2.result.ServletRedirectResult %}
 
-####Examples####
+### Examples
 
+```
+<!--
+  The redirect URL generated will be:
+  /foo.jsp#FRAGMENT
+-->
+<result name="success" type="redirect">
+  <param name="location">foo.jsp</param>
+  <param name="parse">false</param>
+  <param name="anchor">FRAGMENT</param>
+</result>
+```
 
-
-{% snippet id=example|lang=xml|javadoc=true|url=org.apache.struts2.result.ServletRedirectResult %}
-
-
-
-~~~~~~~
+```
 <package name="passingRequestParameters" extends="struts-default" namespace="/passingRequestParameters">
    <-- Pass parameters (reportType, width and height) -->
    <!--
@@ -41,5 +50,4 @@ title: Redirect Result
       </result>
    </action>
 </package>
-
-~~~~~~~
\ No newline at end of file
+```
diff --git a/source/core-developers/stream-result.md b/source/core-developers/stream-result.md
index c5abb4b..2402cd5 100644
--- a/source/core-developers/stream-result.md
+++ b/source/core-developers/stream-result.md
@@ -5,93 +5,31 @@ title: Stream Result
 
 # Stream Result
 
-A custom Result type for sending raw data (via an InputStream) directly to the HttpServletResponse\. Very useful for allowing users to download content\.
+A custom Result type for sending raw data (via an InputStream) directly to the HttpServletResponse. Very useful for allowing users to download content.
+If you are running your app server under HTTPS and having issues with PDF's or other file streams you should take a look at [HTTPS and IE Issues](https-and-ie-issues.html)
 
+### Parameters
 
+- `contentType` - the stream mime-type as sent to the web browser (default = text/plain).
+- `contentLength` - the stream length in bytes (the browser displays a progress bar).
+- `contentDisposition` - the content disposition header value for specifying the file name (default = inline, values are typically attachment;filename="document.pdf".
+- `inputName` - the name of the InputStream property from the chained action (default = inputStream).
+- `bufferSize` - the size of the buffer to copy from input to output (default = 1024).
+- `allowCaching` - if set to 'false' it will set the headers `Pragma` and `Cache-Control` to `no-cahce`, and prevent client from caching the content (default = true).
+- `contentCharSet` - if set to a string, ';charset=value' will be added to the content-type header, where value is the string set. If set to an expression, the result of evaluating the expression will be used. If not set, then no charset will be set on the header
 
-| If you are running your app server under HTTPS and having issues with PDF's or other file streams you should take a look at [HTTPS and IE Issues](https-and-ie-issues.html)
+These parameters can also be set by exposing a similarly named getter method on your Action. For example, you can provide `getContentType()` to override that parameter for the current action. To do it you you must explicitly define this param as an expression i.e. `<param name="contentType">${contentType}</param>`
 
-| 
+Please be aware that this was changed since Struts 2.5.2, previously each parameter was automagically resolved by looking throughout the `ValueStack`, now you must explicitly define which parameter must be evaluated, even `inputName`.
 
-####Parameters####
+### Examples
 
-+ **contentType** \- the stream mime\-type as sent to the web browser (default = 
+#### Annotation based Configuration
 
-~~~~~~~
-text/plain
-~~~~~~~
-)\.
+To configure Actions and Results with Annotations you need to activate the Struts2 _Convention Plugin_ in your Struts2 application.
 
-+ **contentLength** \- the stream length in bytes (the browser displays a progress bar)\.
 
-+ **contentDisposition** \- the content disposition header value for specifying the file name (default = 
-
-~~~~~~~
-inline
-~~~~~~~
-, values are typically _attachment;filename="document\.pdf"_ \.
-
-+ **inputName **\- the name of the InputStream property from the chained action (default = **inputStream**)\.
-
-+ **bufferSize **\- the size of the buffer to copy from input to output (default = 
-
-~~~~~~~
-1024
-~~~~~~~
-)\.
-
-+ **allowCaching** \- if set to 'false' it will set the headers 
-
-~~~~~~~
-Pragma
-~~~~~~~
- and 
-
-~~~~~~~
-Cache-Control
-~~~~~~~
- to 
-
-~~~~~~~
-no-cahce
-~~~~~~~
-, and prevent client from caching the content (default = 
-
-~~~~~~~
-true
-~~~~~~~
-)\.
-
-+ **contentCharSet** \- if set to a string, ';charset=value' will be added to the content\-type header, where value is the string set\. If set to an expression, the result of evaluating the expression will be used\. If not set, then no charset will be set on the header
-
-These parameters can also be set by exposing a similarly named getter method on your Action\. For example, you can provide 
-
-~~~~~~~
-getContentType()
-~~~~~~~
- to override that parameter for the current action\. To do it you you must explicitly define this param as an expression i\.e\.
-
-**parameter defined as an expression**
-
-
-~~~~~~~
-<param name="contentType">${contentType}</param>
-~~~~~~~
-
-
-
-| Please be aware that this was changed since Struts 2\.5\.2, previously each parameter was automagically resolved by looking throughout the ValueStack, now you must explicitly define wich parameter must be evaluated, even inputName\.
-
-| 
-
-####Examples####
-
-#####Annotation based Configuration#####
-
-To configure Actions and Results with Annotations you need to activate the Struts2 _Convention Plugin_  in your Struts2 application\.
-
-
-~~~~~~~
+```
 package com.mycompany.webapp.actions;
 
 import java.io.File;
@@ -140,19 +78,15 @@ public class FileDisplay extends ActionSupport {
 		return this.stream;
 	}
 }
+```
 
-~~~~~~~
-
-#####XML based Configuration#####
-
-**Example configuration**
-
+#### XML based Configuration
 
-~~~~~~~
+```
 <result name="success" type="stream">
   <param name="contentType">image/jpeg</param>
   <param name="inputName">${imageStream}</param>
   <param name="contentDisposition">attachment;filename="document.pdf"</param>
   <param name="bufferSize">1024</param>
 </result>
-~~~~~~~
+```

-- 
To stop receiving notification emails like this one, please contact
['"commits@struts.apache.org" <co...@struts.apache.org>'].