aspose file tools*
The moose likes Struts and the fly likes Passing value (parameter or attribute) from interceptor to action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Passing value (parameter or attribute) from interceptor to action" Watch "Passing value (parameter or attribute) from interceptor to action" New topic
Author

Passing value (parameter or attribute) from interceptor to action

carlos Muller
Greenhorn

Joined: Apr 20, 2006
Posts: 14
Hi everybody, I search this question and don't see any solutions... I don't believe this problem in Struts2 is so difficult:

1) I've an Interceptor where I search an url to go from Database.
2) I've an possible Action (if neccesary) where catch this url that Interceptor search.

Solutions at the moment (no one works)

SOLUTION A)

INTERCEPTOR CODE:

invocation.getStack().setValue("#attr['opcionMenuDirecta']", unica.getUrl());
//OR USE: invocation.getInvocationContext().getParameters().put("directUrl", database.getUrl());

return BaseAction.SUCCESS;


STRUTS.XML CODE:

<result name="success" type="redirectAction">${directUrl}</result>


SOLUTION B)

I can use the action for a alternative solution to my problem, but I can't passing a value from interceptor to the action. I attempt:


INTERCEPTOR CODE:

HttpServletRequest request = (HttpServletRequest)invocation.getInvocationContext().get(HTTP_REQUEST);
request.setAttribute("directUrl", database.getUrl());
//OR USE: invocation.getInvocationContext().getParameters().put("directUrl", database.getUrl());
return BaseAction.SUCCESS;


STRUTS.XML CODE:


<result name="success" type="redirectAction">Action_1?directUrl=${directUrl}</result>
<!-- OR result name="success" type="redirectAction">Action_1</result -->

ACTION_1 CODE:

this.request.getAttribute("directUrl")


THIS SOLUTION, WITH THE STRUTS.XML IN "CHAIN" MODE:
<result name="success" type="chain">Action_1</result>
WORKS, BUT I DON'T WANT TO USE THE CHAIN OPTION.



any solution else?

Thanks in advance




any solution

Thanks in advance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing value (parameter or attribute) from interceptor to action