You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

PreResultListener is provided to allow alteration / cause influence on a particular action invocation (eg. maybe its Result object, switching to a different result, the Action object itself etc) before the Result is being executed. This could be done at the Action object or at the Interceptor itself.

Examples

Action object

  public class MyAction extends ActionSupport {
     ...
     public String execute() throws Exception {
         ActionInvocation invocation = ActionContext.getActionInvocation();
         invocation.addPreResultListener(new PreResultListener() {
              public void beforeResult(ActionInvocation invocation, 
                                       String resultCode) {
                  // perform operation necessary before Result execution
              }
         });
     }
     ...
  }

Interceptor

  public class MyInterceptor extends AbstractInterceptor {
     ...
      public String intercept(ActionInvocation invocation) throws Exception {
         invocation.addPreResultListener(new PreResultListener() {
              public void beforeResult(ActionInvocation invocation, 
                                       String resultCode) {
                  // perform operation necessary before Result execution
              }
         });
      }
     ...
  }
  • No labels