struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From R Veach <rveac...@gmail.com>
Subject Change Action Method In Interceptor
Date Wed, 11 Mar 2015 15:29:08 GMT
Hi,

I know it is possible to limit struts to specific methods using the
MethodFilterInterceptor, and to change the execute method in the config or
form declaration using the method attribute.

Is it possible to have an interceptor change which method would be executed
in the action? I see I can get the method name using
"invocation.getProxy().getMethod()", but I can't find any setter.

One reason I want to do this is to build submit and first time in logic
without defining it everywhere for every page and have an interceptor do
the work for me.
I would identify if it is first time or submit based on request to see if
it is "GET" or "POST".
I could call the methods directly from the interceptor since I have the
action instance, but that would bypass the rest of the interceptor chain
and would require this interceptor to always be last in the list.

Here is an example of what I was planning:

//
if (isFirstTime(request)) {
    if (action instanceof FirstTimeLogic) {
       invocation.getProxy().setMethod("executeFirstTimeInLogic");
    }
} else {
    if (action instanceof SubmitLogic) {
        invocation.getProxy().setMethod("executeSubmitLogic");
    }
}

return invocation.invoke();

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message