You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Brad Cupit (JIRA)" <ji...@apache.org> on 2008/04/17 19:33:05 UTC

[jira] Created: (WW-2598) automatically set ActionMapper for ServletRedirectResult

automatically set ActionMapper for ServletRedirectResult
--------------------------------------------------------

                 Key: WW-2598
                 URL: https://issues.apache.org/struts/browse/WW-2598
             Project: Struts 2
          Issue Type: Improvement
          Components: Core Actions
            Reporter: Brad Cupit
            Priority: Minor


when a ServletRedirectResult (or a subclass of it, like ServletRedirectActionResult) is instantiated and returned as the Result for the Action, the ActionMapper must be manually set by the developer. So, instead of this

// ideal situation
public Result submit() {
	return new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
}

the user must code this:

// manually set the ActionMapper
public Result submit() throws Exception {
	ServletActionRedirectResult result = new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
	result.setActionMapper(actionMapper);
	return result;
}

and to get the ActionMapper in the Action, you have to add this setter:

@Inject
public void setActionMapper(ActionMapper actionMapper) { ... }

This is a feature request/improvement so that the ActionMapper can be automatically set in (or looked up by) the ServletRedirectResult.

see this mailing list post:
http://article.gmane.org/gmane.comp.jakarta.struts.user/155271
and this reply by Don Brown:
http://article.gmane.org/gmane.comp.jakarta.struts.user/155272

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WW-2598) automatically set ActionMapper for ServletRedirectResult

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2598?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Don Brown resolved WW-2598.
---------------------------

    Resolution: Fixed
      Assignee: Don Brown

Fixed as described - results are now autowired

> automatically set ActionMapper for ServletRedirectResult
> --------------------------------------------------------
>
>                 Key: WW-2598
>                 URL: https://issues.apache.org/struts/browse/WW-2598
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>            Reporter: Brad Cupit
>            Assignee: Don Brown
>            Priority: Minor
>             Fix For: 2.1.3
>
>
> when a ServletRedirectResult (or a subclass of it, like ServletRedirectActionResult) is instantiated and returned as the Result for the Action, the ActionMapper must be manually set by the developer. So, instead of this
> // ideal situation
> public Result submit() {
> 	return new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
> }
> the user must code this:
> // manually set the ActionMapper
> public Result submit() throws Exception {
> 	ServletActionRedirectResult result = new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
> 	result.setActionMapper(actionMapper);
> 	return result;
> }
> and to get the ActionMapper in the Action, you have to add this setter:
> @Inject
> public void setActionMapper(ActionMapper actionMapper) { ... }
> This is a feature request/improvement so that the ActionMapper can be automatically set in (or looked up by) the ServletRedirectResult.
> see this mailing list post:
> http://article.gmane.org/gmane.comp.jakarta.struts.user/155271
> and this reply by Don Brown:
> http://article.gmane.org/gmane.comp.jakarta.struts.user/155272

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2598) automatically set ActionMapper for ServletRedirectResult

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43636#action_43636 ] 

Don Brown commented on WW-2598:
-------------------------------

Actually, I was thinking we could just do container.inject(result) in the ActionInvocation object, if we see that the method returns a Result instead of a String.  It should be a pretty easy, backward-compatible fix.

> automatically set ActionMapper for ServletRedirectResult
> --------------------------------------------------------
>
>                 Key: WW-2598
>                 URL: https://issues.apache.org/struts/browse/WW-2598
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>            Reporter: Brad Cupit
>            Priority: Minor
>
> when a ServletRedirectResult (or a subclass of it, like ServletRedirectActionResult) is instantiated and returned as the Result for the Action, the ActionMapper must be manually set by the developer. So, instead of this
> // ideal situation
> public Result submit() {
> 	return new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
> }
> the user must code this:
> // manually set the ActionMapper
> public Result submit() throws Exception {
> 	ServletActionRedirectResult result = new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
> 	result.setActionMapper(actionMapper);
> 	return result;
> }
> and to get the ActionMapper in the Action, you have to add this setter:
> @Inject
> public void setActionMapper(ActionMapper actionMapper) { ... }
> This is a feature request/improvement so that the ActionMapper can be automatically set in (or looked up by) the ServletRedirectResult.
> see this mailing list post:
> http://article.gmane.org/gmane.comp.jakarta.struts.user/155271
> and this reply by Don Brown:
> http://article.gmane.org/gmane.comp.jakarta.struts.user/155272

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2598) automatically set ActionMapper for ServletRedirectResult

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2598?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Don Brown updated WW-2598:
--------------------------

    Fix Version/s: 2.1.3

> automatically set ActionMapper for ServletRedirectResult
> --------------------------------------------------------
>
>                 Key: WW-2598
>                 URL: https://issues.apache.org/struts/browse/WW-2598
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>            Reporter: Brad Cupit
>            Priority: Minor
>             Fix For: 2.1.3
>
>
> when a ServletRedirectResult (or a subclass of it, like ServletRedirectActionResult) is instantiated and returned as the Result for the Action, the ActionMapper must be manually set by the developer. So, instead of this
> // ideal situation
> public Result submit() {
> 	return new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
> }
> the user must code this:
> // manually set the ActionMapper
> public Result submit() throws Exception {
> 	ServletActionRedirectResult result = new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
> 	result.setActionMapper(actionMapper);
> 	return result;
> }
> and to get the ActionMapper in the Action, you have to add this setter:
> @Inject
> public void setActionMapper(ActionMapper actionMapper) { ... }
> This is a feature request/improvement so that the ActionMapper can be automatically set in (or looked up by) the ServletRedirectResult.
> see this mailing list post:
> http://article.gmane.org/gmane.comp.jakarta.struts.user/155271
> and this reply by Don Brown:
> http://article.gmane.org/gmane.comp.jakarta.struts.user/155272

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2598) automatically set ActionMapper for ServletRedirectResult

Posted by "Brad Cupit (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44172#action_44172 ] 

Brad Cupit commented on WW-2598:
--------------------------------

cool, thanks Don!

> automatically set ActionMapper for ServletRedirectResult
> --------------------------------------------------------
>
>                 Key: WW-2598
>                 URL: https://issues.apache.org/struts/browse/WW-2598
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>            Reporter: Brad Cupit
>            Assignee: Don Brown
>            Priority: Minor
>             Fix For: 2.1.3
>
>
> when a ServletRedirectResult (or a subclass of it, like ServletRedirectActionResult) is instantiated and returned as the Result for the Action, the ActionMapper must be manually set by the developer. So, instead of this
> // ideal situation
> public Result submit() {
> 	return new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
> }
> the user must code this:
> // manually set the ActionMapper
> public Result submit() throws Exception {
> 	ServletActionRedirectResult result = new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
> 	result.setActionMapper(actionMapper);
> 	return result;
> }
> and to get the ActionMapper in the Action, you have to add this setter:
> @Inject
> public void setActionMapper(ActionMapper actionMapper) { ... }
> This is a feature request/improvement so that the ActionMapper can be automatically set in (or looked up by) the ServletRedirectResult.
> see this mailing list post:
> http://article.gmane.org/gmane.comp.jakarta.struts.user/155271
> and this reply by Don Brown:
> http://article.gmane.org/gmane.comp.jakarta.struts.user/155272

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2598) automatically set ActionMapper for ServletRedirectResult

Posted by "Jeromy Evans (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43635#action_43635 ] 

Jeromy Evans commented on WW-2598:
----------------------------------

I agree with the issue but not with the proposed approach.  We shouldn't instantiate the Result ourselves using the *new* operator.
Instead we should be asking the Container's ObjectFactory to create a Result with the necessary dependences already injected.

That should be simple, but it's not.  

The ObjectFactory includes a buildResult method but it's not appropriate for use in an action.
Result result = objectFactory.buildResult(resultConfig, invocationContext.getContextMap());

Alternate proposal: expose a new API that requests the container to create a result.

The least effort would be something like this:
eg. return ResultBuilder.createResult("redirectAction").withParam("actionName", "${value1}");
where ResultBuilder either provides a static factory method or an instance can injected into the action 

(I'm not sure if the container supports static injection)



> automatically set ActionMapper for ServletRedirectResult
> --------------------------------------------------------
>
>                 Key: WW-2598
>                 URL: https://issues.apache.org/struts/browse/WW-2598
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>            Reporter: Brad Cupit
>            Priority: Minor
>
> when a ServletRedirectResult (or a subclass of it, like ServletRedirectActionResult) is instantiated and returned as the Result for the Action, the ActionMapper must be manually set by the developer. So, instead of this
> // ideal situation
> public Result submit() {
> 	return new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
> }
> the user must code this:
> // manually set the ActionMapper
> public Result submit() throws Exception {
> 	ServletActionRedirectResult result = new ServletActionRedirectResult("actionName").addParameter("param1", "${value1}");
> 	result.setActionMapper(actionMapper);
> 	return result;
> }
> and to get the ActionMapper in the Action, you have to add this setter:
> @Inject
> public void setActionMapper(ActionMapper actionMapper) { ... }
> This is a feature request/improvement so that the ActionMapper can be automatically set in (or looked up by) the ServletRedirectResult.
> see this mailing list post:
> http://article.gmane.org/gmane.comp.jakarta.struts.user/155271
> and this reply by Don Brown:
> http://article.gmane.org/gmane.comp.jakarta.struts.user/155272

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.