Dashboard > XWork > Documentation > XWork PreResultListeners
  XWork Log In View a printable version of the current page.  
  XWork PreResultListeners
Added by tm_jee, last edited by tm_jee on Oct 14, 2006  (view change)
Labels: 
(None)

PreResultListener serves as a hook to influence the currect action invocation before the result is executed, pretty much clear from the name itself.

Example

Through Action class

public class MyAction extends ActionSupport {
    ...
    public String execute() throws Exception {
       ActionContext context = ActionContext.getContext();
       ActionInvocation invocation = context.getActionInvocation();
       invocation.addPreResultListener(
            new PreResultListener() {
                public void beforeResult(ActionInvocation invocation, String resultCode) {
                   // do my magic here
                }
            });
    }
    ...
  }

Through Interceptor class

public MyInterceptor implements Interceptor {
      ....
      public String intercept(ActionInvocation invocation) throws Exception {
          invocation.addPreResultListener(
            new PreResultListener() {
                public void beforeResult(ActionInvocation invocation, String resultCode) {
                   // do my magic here
                }
            });
      }
      ....
  }

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators