JavaScud | Forum | JIRA | Blog |
  Dashboard > WebWork2文档中文化计划 > ... > FAQ > Can I access my action's Result
  WebWork2文档中文化计划 Log In View a printable version of the current page.  
  Can I access my action's Result
Added by scud, last edited by scud on Mar 30, 2006  (view change)
Labels: 
(None)

Yes, that could be done with the help of an interceptor.

+ Method One +

public class MyInterceptor implements Interceptor {
  ...
	public String intercept(ActionInvocation invocation) throws Exception {
		Map<String, ResultConfig> resultsMap = invocation.getProxy().getConfig().getResults();

                // do something with ResultConfig in map

		return invocation.invoke();
	}
  ...
}

+ Method Two +

public class MyInterceptor implements Interceptor {
  ...
        public String intercept(ActionInvocation invocation) throws Exception {
             invocation.addPreResultListener(new PreResultListener() {
			public void beforeResult(ActionInvocation invocation, String resultCode) {
				Map<String, ResultConfig> resultsMap = invocation.getProxy().getConfig().getResults();
                                ResultConfig finalResultConfig = resultsMap.get(resultCode);
                                
                                // do something interesting with the 'to-be' executed result
			}
	     });

             return invocation.invoke();
        }

  ...
}

The difference between Method One and Two is that method two gives one, the final result to be executed.

Site running on a free Atlassian Confluence Open Source Project License granted to WebWork China. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.3 Build:#808 May 29, 2007) - Bug/feature request - Contact Administrators