| Author |
struts 2: implement PreResultListener
|
Jonathan Su
Greenhorn
Joined: Aug 23, 2007
Posts: 4
|
|
I am trying to have a interceptor called after the Action is executed. In struts.xml I have <interceptors> <interceptor name="accessControl" class="org.kp.pharmacy.sdp.web.interceptor.MemberInquiryAccessControlInterceptor"/> </interceptors> <action name="launch" class="org.kp.pharmacy.sdp.web.action.MemberInquiryAction" > <interceptor-ref name="defaultStack"/> <interceptor-ref name="accessControl"/> <result name="success">jsp/MemberInquiry.jsp</result> <result name="error">jsp/error.jsp</result> </action> 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()); action.getMemberInquiryAccess().setReadOnlyMode(); } else { action.setMemberInquiryAccess(new MemberInquiryAccessBean()); action.getMemberInquiryAccess().setEditMode(); } return; } } However this interceptor doesn't get called after the action. Could anybody tell me what I am missing? Thanks,
|
 |
Dmitriy Kuznetsov
Greenhorn
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:
http://struts.apache.org/2.x/docs/can-we-access-an-actions-result.html
|
 |
 |
|
|
subject: struts 2: implement PreResultListener
|
|
|