File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes struts 2: implement PreResultListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2: implement PreResultListener" Watch "struts 2: implement PreResultListener" New topic

struts 2: implement PreResultListener

Jonathan Su

Joined: Aug 23, 2007
Posts: 4
I am trying to have a interceptor called after the Action is executed.

In struts.xml I have

<interceptor name="accessControl" class=""/>

<action name="launch" class="" >
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="accessControl"/>
<result name="success">jsp/MemberInquiry.jsp</result>
<result name="error">jsp/error.jsp</result>

The the interceptor is like this:
public class MemberInquiryAccessControlInterceptor implements PreResultListener{

public void beforeResult(ActionInvocation invocation, String result) {
MemberInquiryAction action = (MemberInquiryAction)invocation.getAction();
if (action.getMrnNumber() == null || action.getRegionCode() == null || action.isMultipleMember()) {
action.setMemberInquiryAccess(new MemberInquiryAccessBean());
else {
action.setMemberInquiryAccess(new MemberInquiryAccessBean());

However this interceptor doesn't get called after the action. Could anybody tell me what I am missing?

Dmitriy Kuznetsov

Joined: Feb 05, 2010
Posts: 5
It seems, that MemberInquiryAccessControlInterceptor must implement Interceptor(instead of PreResultListener) to be invoked.

And i couldn't find a way to attach PreResultListener to action through struts.xml directly. So, the thing is to implement Interceptor, which attaches PreResultListener to ActionInvocation. E.g:

I agree. Here's the link:
subject: struts 2: implement PreResultListener
It's not a secret anymore!