You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2022/10/13 11:45:46 UTC
[struts-site] 02/02: Explains how to use results
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch results
in repository https://gitbox.apache.org/repos/asf/struts-site.git
commit 2221151387ae68146538deeab2743961371fb7b9
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Thu Oct 13 13:45:38 2022 +0200
Explains how to use results
---
source/core-developers/result-types.md | 43 ++++++++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 5 deletions(-)
diff --git a/source/core-developers/result-types.md b/source/core-developers/result-types.md
index c85a6d081..31d9b59d9 100644
--- a/source/core-developers/result-types.md
+++ b/source/core-developers/result-types.md
@@ -26,17 +26,50 @@ own applications.
|[Plain Result](plain-result)|A plain result which all you to write directly to a HttpResponse using a simplified API (since Struts 2.6)|
|[PlainText Result](plaintext-result)|Used to display the raw content of a particular file/page (i.e jsp, HTML)|
|[Tiles Result](../plugins/tiles/)|Used to provide Tiles integration|
-|[Tiles 3 Result](../plugins/tiles-3/)|Used to provide Tiles 3 integration|
|[Postback Result](postback-result)|Used to postback request parameters as a form to the specified destination|
|[JSON Result](../plugins/json/) |Used to serialize actions into JSON|
-
-## Optional
-
-|[JasperReports Plugin](../plugins/jasperreports/)|Used for [JasperReports Tutorial](../getting-started/jasper-reports-tutorial) integration|Optional, third-party plugin|
+|[JasperReports Plugin](../plugins/jasperreports/)|Used for [JasperReports Tutorial](../getting-started/jasper-reports-tutorial) integration|
Additional Result Types can be created and plugged into an application by implementing the `com.opensymphony.xwork2.Result`
interface. Custom Result Types might include generating an email or JMS message, generating images, and so forth.
+## How to use results
+
+Once your action has been executed it must either return a result name (as `java.lang.String`) or instance
+of `com.opensymphony.xwork2.Result` and the result will be executed directly.
+
+If a String has been returned, the framework will try to find a matching result in the configuration and then it will
+execute the result of a given type, see example:
+
+```xml
+<result name="success" type="dispatcher">/WEB-INF/index.jsp</result>
+```
+
+You can define many results per action distinguishing them by different names.
+
+```xml
+<result name="success" type="dispatcher">/WEB-INF/index.jsp</result>
+<result name="input" type="dispatcher">/WEB-INF/form.jsp</result>
+<result name="error" type="dispatcher">/WEB-INF/error.jsp</result>
+```
+
+## Default result type
+
+In `struts-default.xml` the Dispatcher result type is registered as a default result type, which means you don't have to
+specify the `type` attribute if yoy want to use it:
+
+```xml
+<result name="success">/WEB-INF/index.jsp</result>
+```
+
+## Default result name
+
+If you action method returns `success`, which is a default name of the result, you don't have specify the `name` attribute as well:
+
+```xml
+<result>/WEB-INF/index.jsp</result>
+```
+
## Default Parameters
To minimize configuration, Results can be configured with a single value, which will be converted into a parameter,