struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [struts-site] branch master updated: WW-5080 Adds docs for PlainResult
Date Thu, 05 Nov 2020 12:33:51 GMT
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart 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 fca7ed7  WW-5080 Adds docs for PlainResult
fca7ed7 is described below

commit fca7ed739bd2c6f0dc8e7b9e5fa557112c73f64c
Author: Lukasz Lenart <lukaszlenart@apache.org>
AuthorDate: Thu Nov 5 13:33:44 2020 +0100

    WW-5080 Adds docs for PlainResult
---
 source/core-developers/plain-result.md | 40 ++++++++++++++++++++++++++++++++++
 source/core-developers/result-types.md |  3 ++-
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/source/core-developers/plain-result.md b/source/core-developers/plain-result.md
new file mode 100644
index 0000000..7a2593f
--- /dev/null
+++ b/source/core-developers/plain-result.md
@@ -0,0 +1,40 @@
+---
+layout: default
+title: Plain Result
+parent:
+    title: Core Developers Guide
+    url: index.html
+---
+
+# Plain Result
+
+## Description
+
+You create this result programmatically in an action and return it as a result of the action.
No result definition
+is needed in `struts.xml`. See the examples below how to use it. Please notice that the method
result type is `PlainResult`
+instead of `String`. Please explore the API for more methods - if any is missing you can
either extends the interface
+or report it in [JIRA](https://issues.apache.org/jira/projects/WW/).
+
+> NOTE: This result is available since Struts 2.6 and it requires Java 8 
+
+## Parameters
+
+no parameters
+ 
+## Examples
+
+```Java
+public class UserAction {
+
+    private String id;
+
+    public PlainResult execute() {
+        return response -> response.write("User Id: " + id);
+    }
+
+    public PlainResult html() {
+        return response -> response.write("<b>test</b>").withContentTypeTextHtml();
+    }
+
+}
+```
diff --git a/source/core-developers/result-types.md b/source/core-developers/result-types.md
index 7d27911..36a5dc0 100644
--- a/source/core-developers/result-types.md
+++ b/source/core-developers/result-types.md
@@ -23,7 +23,8 @@ own applications.
 |[Stream Result](stream-result.html)|Used to stream an InputStream back to the browser (usually
for file downloads)|
 |[Velocity Result](velocity-result.html)|Used for _Velocity_  integration|
 |[XSL Result](xsl-result.html)|Used for XML/XSLT integration|
-|[PlainText Result](plaintext-result.html)|Used to display the raw content of a particular
page (i.e jsp, HTML)|
+|[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.html)|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.html)|Used to postback request parameters as a form to
the specified destination|


Mime
View raw message