You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joe Mun <yc...@sbcglobal.net> on 2006/03/09 00:42:49 UTC
DispatchAction: Invalid Method call
Using DispatchAction, if a non-existent method name is
passed, a java.lang.NoSuchMethodException is thrown.
How (and where) can I catch (and ignore) this
exception, so that invalid methods default to
"unspecified(..)"???
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DispatchAction: Invalid Method call
Posted by Michael Jouravlev <jm...@gmail.com>.
DispatchAction sucks. Use
http://wiki.apache.org/struts/EventActionDispatcher It is so much
better. It is Javascript-free and allows to set arbitrary caption for
your button.
You can get it from here:
http://issues.apache.org/bugzilla/attachment.cgi?id=17724
or from here:
http://svn.apache.org/viewcvs.cgi/struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions/EventActionDispatcher.java?rev=384134&view=markup
Michael.
On 3/8/06, Joe Mun <yc...@sbcglobal.net> wrote:
> The "unspecified()" method is only invoked if the
> parameter wasn't passed in. However, when an invalid
> method name is passed in, a
> java.lang.NoSuchMethodException exception is thrown.
>
> If possible, I want "unspecified()" to be invoked for
> invalid method names also...
>
> Example... parameter name: "param"
> param=validMethod => DispatchAction.validMethod()
> param=NULL => DispatchAction.unspecified()
> param=invalidMethod => NoSuchMethodException is
> THROWN!!
>
> thanks.
>
> --- Paul Benedict <pa...@yahoo.com> wrote:
>
> > Joe, override the unspecified method. That method
> > is invoked whenever the dispatch cannot be resolved.
> >
> > --- Joe Mun <yc...@sbcglobal.net> wrote:
> >
> > > Using DispatchAction, if a non-existent method
> > name is
> > > passed, a java.lang.NoSuchMethodException is
> > thrown.
> > > How (and where) can I catch (and ignore) this
> > > exception, so that invalid methods default to
> > > "unspecified(..)"???
> > >
> > > Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DispatchAction: Invalid Method call
Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
How about using an exception handler to catch both unspecified and invalid
method names? I recently added "dispatch" flavour examples (primarily for
testing) to the struts-examples webapp - you can take a look at them in the
nightly build if thats of interest:
http://svn.apache.org/builds/struts/maven/STRUTS_1_2_BRANCH/nightly/binary/
Otherwise, you could override the dispatchMethod and catch the
NoSuchMethodException, although IMO this is a bad idea, since it could hide
bugs/attacks (depending on what you put in the unspecified method).
protected ActionForward dispatchMethod(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response,
String name) throws Exception {
try {
return super.dispatchMethod(mapping, form, request. response);
} catch(NoSuchMethodException ex) {
return unspecified(mapping, form, request, response);
}
}
Niall
----- Original Message -----
From: "Joe Mun" <yc...@sbcglobal.net>
Sent: Thursday, March 09, 2006 12:55 AM
> The "unspecified()" method is only invoked if the
> parameter wasn't passed in. However, when an invalid
> method name is passed in, a
> java.lang.NoSuchMethodException exception is thrown.
>
> If possible, I want "unspecified()" to be invoked for
> invalid method names also...
>
> Example... parameter name: "param"
> param=validMethod => DispatchAction.validMethod()
> param=NULL => DispatchAction.unspecified()
> param=invalidMethod => NoSuchMethodException is
> THROWN!!
>
> thanks.
>
> --- Paul Benedict <pa...@yahoo.com> wrote:
>
> > Joe, override the unspecified method. That method
> > is invoked whenever the dispatch cannot be resolved.
> >
> > --- Joe Mun <yc...@sbcglobal.net> wrote:
> >
> > > Using DispatchAction, if a non-existent method
> > name is
> > > passed, a java.lang.NoSuchMethodException is
> > thrown.
> > > How (and where) can I catch (and ignore) this
> > > exception, so that invalid methods default to
> > > "unspecified(..)"???
> > >
> > > Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DispatchAction: Invalid Method call
Posted by Joe Mun <yc...@sbcglobal.net>.
The "unspecified()" method is only invoked if the
parameter wasn't passed in. However, when an invalid
method name is passed in, a
java.lang.NoSuchMethodException exception is thrown.
If possible, I want "unspecified()" to be invoked for
invalid method names also...
Example... parameter name: "param"
param=validMethod => DispatchAction.validMethod()
param=NULL => DispatchAction.unspecified()
param=invalidMethod => NoSuchMethodException is
THROWN!!
thanks.
--- Paul Benedict <pa...@yahoo.com> wrote:
> Joe, override the unspecified method. That method
> is invoked whenever the dispatch cannot be resolved.
>
> --- Joe Mun <yc...@sbcglobal.net> wrote:
>
> > Using DispatchAction, if a non-existent method
> name is
> > passed, a java.lang.NoSuchMethodException is
> thrown.
> > How (and where) can I catch (and ignore) this
> > exception, so that invalid methods default to
> > "unspecified(..)"???
> >
> > Thanks!
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: DispatchAction: Invalid Method call
Posted by Paul Benedict <pa...@yahoo.com>.
Joe, override the unspecified method. That method
is invoked whenever the dispatch cannot be resolved.
--- Joe Mun <yc...@sbcglobal.net> wrote:
> Using DispatchAction, if a non-existent method name is
> passed, a java.lang.NoSuchMethodException is thrown.
> How (and where) can I catch (and ignore) this
> exception, so that invalid methods default to
> "unspecified(..)"???
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org