You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by GitBox <gi...@apache.org> on 2020/07/06 06:05:15 UTC

[GitHub] [struts] lukaszlenart commented on pull request #422: [WW-5080] Defines a new result type plain to use directly with Java code

lukaszlenart commented on pull request #422:
URL: https://github.com/apache/struts/pull/422#issuecomment-654033477


   > Shouldn't we do something in configs, allowing developer to define this result via struts.xml as well?
   
   No, this result is a plain code-based-result, you cannot define it in `struts.xml` and it can only be returned directly from an action. `DefaultActionInvocation` [supports](https://github.com/apache/struts/blob/master/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java#L472-L478) returning results directly from actions for a long time.
   
   > Already there is a PlainTextResult, shouldn't we amend it to extend this result?
   
   No, the `PlainTextResult` result returns content of a file as a plain text. This new result allows output any type of content (text, JSON, html) but you must build it by a hand. That's why I decided to name it a `PlainResult` and with Java 8 you can use lambdas to construct the output:
   
   ```java
       public PlainResult execute() {
           return response -> response.write("ok");
       }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org