struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Sykes <a.sy...@ucl.ac.uk>
Subject Casting an action to an interface
Date Fri, 30 Jan 2009 00:49:39 GMT
Hi all,

I've written an interceptor with a PreResultListener that gets the  
action with ActionInvocation.getAction(), then casts it to an  
interface ("Parseable", in this case). This lets me call a particular  
method on the action just prior to the result being rendered.

The action implements Parseable and SessionAware.

When I do the cast, I get an ClassCastException for  
com.opensymphony.xwork2.ActionSupport. If I take it down to one  
interface (SessionAware) and cast the action to it, I still get a CCE.  
What's weirder is I'm pretty sure this code worked on Struts 2.0.11.

Here's a suitably simplified version of what I'm attempting to do:

public String intercept(ActionInvocation invocation) throws Exception {
         invocation.addPreResultListener(new PreResultListener() {
               public void beforeResult(ActionInvocation invocation,  
String resultCode) {
                 Action action = (Action)invocation.getAction();
                 if (action instanceof Parseable) {
                     ((Parseable)action).parse();
                 }
               }
     });

Any ideas what the hell is going on here?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message