You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel Ruan <da...@gmail.com> on 2009/02/13 17:40:16 UTC
Struts2: change method to invoke on the fly??
Is it possible to write an Action Interceptor, which can set the method to
invoke on the fly, depending on certain runtime variables?
I can get the ActionProxy from ActionInvocation, but the proxy provides only
a getter getMethod() not a setter. Any ideas?
Thanks,
Daniel
Re: Struts2: change method to invoke on the fly??
Posted by Daniel Ruan <da...@gmail.com>.
Thanks, Scott.
Yes, I had something else in mind. I need to give a URL to a third party
site for call back and I will also need to pass a parameter, but that third
party always strips off all query parameters. One idea I had was to append
the parameter to the action name as if a wild card method, e.g.,
blah_value123, blah_value456. Apparently "value123" and "value466" are not
real method names, so I would have the interceptor call the execute method
instead after setting an action property to "value123" or "value456". Hence
my question.
Then I thought of a better solution using url rewriting. I will rewrite the
URL like blah_value123 to blah?paramName=value123 . I am not using the REST
plug in, which will solve the problem too.
Cheers,
Daniel
On Fri, Feb 13, 2009 at 12:44 PM, <st...@gmail.com> wrote:
> I'm not real sure what you have in mind here, but this works very nicely:
>
>
> <action name="blah-*" method="{1}"
> class="acme.action.BlahAction">
> ...
> </action>
>
> request for www.//blah-fred fires the fred() method and
> request for www.//blah-barney fires the barney method
>
> Peace,
> Scott
>
>
>
> On Fri, Feb 13, 2009 at 10:40 AM, Daniel Ruan <da...@gmail.com>
> wrote:
>
> > Is it possible to write an Action Interceptor, which can set the method
> to
> > invoke on the fly, depending on certain runtime variables?
> >
> > I can get the ActionProxy from ActionInvocation, but the proxy provides
> > only
> > a getter getMethod() not a setter. Any ideas?
> >
> > Thanks,
> >
> > Daniel
> >
>
Re: Struts2: change method to invoke on the fly??
Posted by st...@gmail.com.
I'm not real sure what you have in mind here, but this works very nicely:
<action name="blah-*" method="{1}"
class="acme.action.BlahAction">
...
</action>
request for www.//blah-fred fires the fred() method and
request for www.//blah-barney fires the barney method
Peace,
Scott
On Fri, Feb 13, 2009 at 10:40 AM, Daniel Ruan <da...@gmail.com> wrote:
> Is it possible to write an Action Interceptor, which can set the method to
> invoke on the fly, depending on certain runtime variables?
>
> I can get the ActionProxy from ActionInvocation, but the proxy provides
> only
> a getter getMethod() not a setter. Any ideas?
>
> Thanks,
>
> Daniel
>