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" <[EMAIL PROTECTED]>
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 <[EMAIL PROTECTED]> wrote:
>
> > Joe, override the unspecified method. That method
> > is invoked whenever the dispatch cannot be resolved.
> >
> > --- Joe Mun <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to