Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

PreResultListener is provided to allow alteration / cause influence on a particular action invocation (eg. maybe its Result object, A PreResultListener can affect an action invocation between the interceptor/action phase and the result phase. Typical uses include switching to a different result, the Action object itself etc) Result or somehow modifying the Result or Action objects before the Result is being executed. This could be done at the Action object or at the Interceptor itself.

Examples

...

executes.

Examples

A PreResultListener can be added by an Action or an Interceptor.

By an Action

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

By an Interceptor

Code Block
  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
              }
         });
      }
     ...
  }

Next: Localization