You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Philippe Calvé <ph...@scanpak.com> on 2003/05/14 23:18:11 UTC

Calling method directly from URL with LookupDispatchAction

Hi,

Calling a method with a "DispatchAction" directly on the URL works perfectly

http://server:8080/app/action.do?action=update

But with a "LookupDispatchAction" what you need to put into the mapping to make it works ?

By the way, is it possible to call a "default" function if no parameter is provided ?  

Thanks,

Philippe C.

Re: Calling method directly from URL with LookupDispatchAction

Posted by Philippe Calvé <ph...@scanpak.com>.
I'm answering to myself but maybe someone else one day will need this
information :)

To be able to call methods with LookupDispatchAction you need to set the
mapping like that :

  protected Map getKeyMethodMap()
  {
      Map map = new HashMap();
      // Form buttons
      map.put("buttons.add", "add");
      map.put("buttons.delete", "delete");
      map.put("buttons.modify", "modify");
      map.put("buttons.update", "update");

      // Command line
      map.put("actions.populate", "populate");

      // Default function
      map.put(null, "populate");
      return map;
  }

And create an entry for "actions.populate" with the text you want. In my
case : actions.populate=populate.

This code handle something like :

http://calvepw2ktest:8181/lopa/management/modifCompTypes.do?action=

But i cant handle this :

http://calvepw2ktest:8181/lopa/management/modifCompTypes.do

I'm having this error :

javax.servlet.ServletException: Request[/management/modifCompTypes] does not
contain handler parameter named action

Should I fix the problem by catching "javax.servlet.ServletException"
exceptions in struts-config.xml and redirecting to a correct URL in case of
error ?!?! ...

Philippe.

----- Original Message ----- 
From: "Philippe Calvé" <ph...@scanpak.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, May 14, 2003 5:33 PM
Subject: Re: Calling method directly from URL with LookupDispatchAction


> Thanks for your answer, I will check for this function.
>
> But the main problem is that currently i'm trying to populate a form by
> calling the action on the URL and then handle multiple buttons for this
> form:
>
>
http://calvepw2ktest:8181/lopa/management/modifCompTypes.do?action=populate
>
> My mapping configuration (all functions are declared correctly):
>
>   protected Map getKeyMethodMap()
>   {
>       Map map = new HashMap();
>       map.put("buttons.add", "add");
>       map.put("buttons.delete", "delete");
>       map.put("buttons.modify", "modify");
>       map.put("buttons.update", "update");
>       map.put("populate", "populate");
>       return map;
>   }
>
> The error I got:
>
> HTTP Status 400 - Request[/management/modifCompTypes] does not contain
> handler parameter named action
>
> type Status report
> message Request[/management/modifCompTypes] does not contain handler
> parameter named action
> description The request sent by the client was syntactically incorrect
> (Request[/management/modifCompTypes] does not contain handler parameter
> named action).
>
> Apache Tomcat/4.1.18
>
> Doing this with a normal "DispatchAction" works perfectly but with the
> lookup addition it's another thing ;)
>
> Thanks again,
>
> Philippe.
>
> ----- Original Message ----- 
> From: "Mike Jasnowski" <mj...@bea.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, May 14, 2003 5:20 PM
> Subject: RE: Calling method directly from URL with LookupDispatchAction
>
>
> > I believe there is a method called "unspecified()" or something close to
> > that, which will be called if no method is provided. But, the default
> > implementation of that method returns a 404 response I think, which can
be
> > confusing.
> >
> > -----Original Message-----
> > From: Philippe Calvé [mailto:philippec@scanpak.com]
> > Sent: Wednesday, May 14, 2003 5:18 PM
> > To: Struts Users Mailing List
> > Subject: Calling method directly from URL with LookupDispatchAction
> >
> >
> > Hi,
> >
> > Calling a method with a "DispatchAction" directly on the URL works
> perfectly
> >
> > http://server:8080/app/action.do?action=update
> >
> > But with a "LookupDispatchAction" what you need to put into the mapping
to
> > make it works ?
> >
> > By the way, is it possible to call a "default" function if no parameter
is
> > provided ?
> >
> > Thanks,
> >
> > Philippe C.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: Calling method directly from URL with LookupDispatchAction

Posted by Philippe Calvé <ph...@scanpak.com>.
Thanks for your answer, I will check for this function.

But the main problem is that currently i'm trying to populate a form by
calling the action on the URL and then handle multiple buttons for this
form:

http://calvepw2ktest:8181/lopa/management/modifCompTypes.do?action=populate

My mapping configuration (all functions are declared correctly):

  protected Map getKeyMethodMap()
  {
      Map map = new HashMap();
      map.put("buttons.add", "add");
      map.put("buttons.delete", "delete");
      map.put("buttons.modify", "modify");
      map.put("buttons.update", "update");
      map.put("populate", "populate");
      return map;
  }

The error I got:

HTTP Status 400 - Request[/management/modifCompTypes] does not contain
handler parameter named action

type Status report
message Request[/management/modifCompTypes] does not contain handler
parameter named action
description The request sent by the client was syntactically incorrect
(Request[/management/modifCompTypes] does not contain handler parameter
named action).

Apache Tomcat/4.1.18

Doing this with a normal "DispatchAction" works perfectly but with the
lookup addition it's another thing ;)

Thanks again,

Philippe.

----- Original Message ----- 
From: "Mike Jasnowski" <mj...@bea.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, May 14, 2003 5:20 PM
Subject: RE: Calling method directly from URL with LookupDispatchAction


> I believe there is a method called "unspecified()" or something close to
> that, which will be called if no method is provided. But, the default
> implementation of that method returns a 404 response I think, which can be
> confusing.
>
> -----Original Message-----
> From: Philippe Calvé [mailto:philippec@scanpak.com]
> Sent: Wednesday, May 14, 2003 5:18 PM
> To: Struts Users Mailing List
> Subject: Calling method directly from URL with LookupDispatchAction
>
>
> Hi,
>
> Calling a method with a "DispatchAction" directly on the URL works
perfectly
>
> http://server:8080/app/action.do?action=update
>
> But with a "LookupDispatchAction" what you need to put into the mapping to
> make it works ?
>
> By the way, is it possible to call a "default" function if no parameter is
> provided ?
>
> Thanks,
>
> Philippe C.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


RE: Calling method directly from URL with LookupDispatchAction

Posted by Mike Jasnowski <mj...@bea.com>.
I believe there is a method called "unspecified()" or something close to
that, which will be called if no method is provided. But, the default
implementation of that method returns a 404 response I think, which can be
confusing.

-----Original Message-----
From: Philippe Calvé [mailto:philippec@scanpak.com]
Sent: Wednesday, May 14, 2003 5:18 PM
To: Struts Users Mailing List
Subject: Calling method directly from URL with LookupDispatchAction


Hi,

Calling a method with a "DispatchAction" directly on the URL works perfectly

http://server:8080/app/action.do?action=update

But with a "LookupDispatchAction" what you need to put into the mapping to
make it works ?

By the way, is it possible to call a "default" function if no parameter is
provided ?

Thanks,

Philippe C.


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