You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kunal Parikh <ku...@carsales.com.au> on 2004/08/16 07:30:35 UTC

Mapping ActionPath to a method in DispatchAction

Hi!

I was wondering if it were possible to drop the parameter attribute in a  
dispatch action and map an actionPath to a method/methodName ?

E.g

/createUser -> public ActionForward createUser(ActionMapping m,ActionForm  
f,HttpServletRequest req,HttpServletResponse res )

/editUser -> public ActionForward createUser(ActionMapping m,ActionForm  
f,HttpServletRequest req,HttpServletResponse res )

/deleteUser -> public ActionForward deleteUser(ActionMapping m,ActionForm  
f,HttpServletRequest req,HttpServletResponse res )

instead of

/userAction?method=createUser -> public ActionForward  
createUser(ActionMapping m,ActionForm f,HttpServletRequest  
req,HttpServletResponse res )

/userAction?method=editUserUser -> public ActionForward  
editUser(ActionMapping m,ActionForm f,HttpServletRequest  
req,HttpServletResponse res )

/userAction?method=deleteUser -> public ActionForward  
deleteUser(ActionMapping m,ActionForm f,HttpServletRequest  
req,HttpServletResponse res )

TIA,

Kunal


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


RE: Mapping ActionPath to a method in DispatchAction

Posted by Amit Kumar Sharma <am...@sysarris.soft.net>.
Try lookupDispatchAction instead of DispatchAction and have a message
resources(applicationresource.properties) for the mappings...that you
way you can achieve multiple submits as well as no need to check for the
method parameter.
You need to check for the html:submit code for that.

Regards
Amit

-----Original Message-----
From: Kunal Parikh [mailto:kunalp@carsales.com.au] 
Sent: Monday, August 16, 2004 11:28 AM
To: Struts Users Mailing List
Subject: Re: Mapping ActionPath to a method in DispatchAction

That is EXACTLY what I've done:

Changed the last line of the execute method of dispatch action FROM

return dispatchMethod(mapping, form, request, response, name);
                                                         ^^^^
TO

return dispatchMethod(mapping, form, request, response, parameter);
                                                         ^^^^^^^^^
But, is there a more "standard" way of achieving the same functionality
?


TIA,

Kunal


On Mon, 16 Aug 2004 11:22:11 +0530, Navjot Singh
<na...@net4india.net>  
wrote:

> 110% POSSIBLE.
>
> retreiving the paramter name and method calls using reflection and are

> already done.
> all you need to do is override the implementation and rather than  
> checking for *method* value , check for last part of URI and call the

> respective method.
>
> just change execute() method in DispatchAction. you dont have to do  
> much. just a few lines.
>
> regards
> Navjot Singh
>
> Kunal Parikh wrote:
>
>> Hi!
>>
>> I was wondering if it were possible to drop the parameter attribute
in  
>> a  dispatch action and map an actionPath to a method/methodName ?
>>
>> E.g
>>
>> /createUser -> public ActionForward createUser(ActionMapping  
>> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>>
>> /editUser -> public ActionForward createUser(ActionMapping  
>> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>>
>> /deleteUser -> public ActionForward deleteUser(ActionMapping  
>> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>>
>> instead of
>>
>> /userAction?method=createUser -> public ActionForward   
>> createUser(ActionMapping m,ActionForm f,HttpServletRequest   
>> req,HttpServletResponse res )
>>
>> /userAction?method=editUserUser -> public ActionForward   
>> editUser(ActionMapping m,ActionForm f,HttpServletRequest   
>> req,HttpServletResponse res )
>>
>> /userAction?method=deleteUser -> public ActionForward   
>> deleteUser(ActionMapping m,ActionForm f,HttpServletRequest   
>> req,HttpServletResponse res )
>>
>> TIA,
>>
>> Kunal
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>> .
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>




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


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


Re: Mapping ActionPath to a method in DispatchAction

Posted by Kunal Parikh <ku...@carsales.com.au>.
That is EXACTLY what I've done:

Changed the last line of the execute method of dispatch action FROM

return dispatchMethod(mapping, form, request, response, name);
                                                         ^^^^
TO

return dispatchMethod(mapping, form, request, response, parameter);
                                                         ^^^^^^^^^
But, is there a more "standard" way of achieving the same functionality ?


TIA,

Kunal


On Mon, 16 Aug 2004 11:22:11 +0530, Navjot Singh <na...@net4india.net>  
wrote:

> 110% POSSIBLE.
>
> retreiving the paramter name and method calls using reflection and are  
> already done.
> all you need to do is override the implementation and rather than  
> checking for *method* value , check for last part of URI and call the  
> respective method.
>
> just change execute() method in DispatchAction. you dont have to do  
> much. just a few lines.
>
> regards
> Navjot Singh
>
> Kunal Parikh wrote:
>
>> Hi!
>>
>> I was wondering if it were possible to drop the parameter attribute in  
>> a  dispatch action and map an actionPath to a method/methodName ?
>>
>> E.g
>>
>> /createUser -> public ActionForward createUser(ActionMapping  
>> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>>
>> /editUser -> public ActionForward createUser(ActionMapping  
>> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>>
>> /deleteUser -> public ActionForward deleteUser(ActionMapping  
>> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>>
>> instead of
>>
>> /userAction?method=createUser -> public ActionForward   
>> createUser(ActionMapping m,ActionForm f,HttpServletRequest   
>> req,HttpServletResponse res )
>>
>> /userAction?method=editUserUser -> public ActionForward   
>> editUser(ActionMapping m,ActionForm f,HttpServletRequest   
>> req,HttpServletResponse res )
>>
>> /userAction?method=deleteUser -> public ActionForward   
>> deleteUser(ActionMapping m,ActionForm f,HttpServletRequest   
>> req,HttpServletResponse res )
>>
>> TIA,
>>
>> Kunal
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>> .
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>




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


Re: Mapping ActionPath to a method in DispatchAction

Posted by Navjot Singh <na...@net4india.net>.
but then it wont remain a DisptachAction anymore ;-) as control will not 
reach same class for multiple actions.

regards
Navjot Singh

Navjot Singh wrote:

> 110% POSSIBLE.
>
> retreiving the paramter name and method calls using reflection and are 
> already done.
> all you need to do is override the implementation and rather than 
> checking for *method* value , check for last part of URI and call the 
> respective method.
>
> just change execute() method in DispatchAction. you dont have to do 
> much. just a few lines.
>
> regards
> Navjot Singh
>
> Kunal Parikh wrote:
>
>> Hi!
>>
>> I was wondering if it were possible to drop the parameter attribute 
>> in a  dispatch action and map an actionPath to a method/methodName ?
>>
>> E.g
>>
>> /createUser -> public ActionForward createUser(ActionMapping 
>> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>>
>> /editUser -> public ActionForward createUser(ActionMapping 
>> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>>
>> /deleteUser -> public ActionForward deleteUser(ActionMapping 
>> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>>
>> instead of
>>
>> /userAction?method=createUser -> public ActionForward  
>> createUser(ActionMapping m,ActionForm f,HttpServletRequest  
>> req,HttpServletResponse res )
>>
>> /userAction?method=editUserUser -> public ActionForward  
>> editUser(ActionMapping m,ActionForm f,HttpServletRequest  
>> req,HttpServletResponse res )
>>
>> /userAction?method=deleteUser -> public ActionForward  
>> deleteUser(ActionMapping m,ActionForm f,HttpServletRequest  
>> req,HttpServletResponse res )
>>
>> TIA,
>>
>> Kunal
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>> .
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> .
>

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


Re: Mapping ActionPath to a method in DispatchAction

Posted by Navjot Singh <na...@net4india.net>.
110% POSSIBLE.

retreiving the paramter name and method calls using reflection and are 
already done.
all you need to do is override the implementation and rather than 
checking for *method* value , check for last part of URI and call the 
respective method.

just change execute() method in DispatchAction. you dont have to do 
much. just a few lines.

regards
Navjot Singh

Kunal Parikh wrote:

> Hi!
>
> I was wondering if it were possible to drop the parameter attribute in 
> a  dispatch action and map an actionPath to a method/methodName ?
>
> E.g
>
> /createUser -> public ActionForward createUser(ActionMapping 
> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>
> /editUser -> public ActionForward createUser(ActionMapping 
> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>
> /deleteUser -> public ActionForward deleteUser(ActionMapping 
> m,ActionForm  f,HttpServletRequest req,HttpServletResponse res )
>
> instead of
>
> /userAction?method=createUser -> public ActionForward  
> createUser(ActionMapping m,ActionForm f,HttpServletRequest  
> req,HttpServletResponse res )
>
> /userAction?method=editUserUser -> public ActionForward  
> editUser(ActionMapping m,ActionForm f,HttpServletRequest  
> req,HttpServletResponse res )
>
> /userAction?method=deleteUser -> public ActionForward  
> deleteUser(ActionMapping m,ActionForm f,HttpServletRequest  
> req,HttpServletResponse res )
>
> TIA,
>
> Kunal
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> .
>

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


Re: Mapping ActionPath to a method in DispatchAction

Posted by Hubert Rabago <ja...@yahoo.com>.
If you're using Struts 1.2.x or the nightly builds, take a look at the
MappingDispatchAction.  It does exactly what you're looking for.

http://struts.apache.org/api/org/apache/struts/actions/MappingDispatchAction.html

hth,
Hubert

--- Kunal Parikh <ku...@carsales.com.au> wrote:

> Hi!
> 
> I was wondering if it were possible to drop the parameter attribute in a  
> dispatch action and map an actionPath to a method/methodName ?
> 
> E.g
> 
> /createUser -> public ActionForward createUser(ActionMapping m,ActionForm  
> f,HttpServletRequest req,HttpServletResponse res )
> 
> /editUser -> public ActionForward createUser(ActionMapping m,ActionForm  
> f,HttpServletRequest req,HttpServletResponse res )
> 
> /deleteUser -> public ActionForward deleteUser(ActionMapping m,ActionForm  
> f,HttpServletRequest req,HttpServletResponse res )
> 
> instead of
> 
> /userAction?method=createUser -> public ActionForward  
> createUser(ActionMapping m,ActionForm f,HttpServletRequest  
> req,HttpServletResponse res )
> 
> /userAction?method=editUserUser -> public ActionForward  
> editUser(ActionMapping m,ActionForm f,HttpServletRequest  
> req,HttpServletResponse res )
> 
> /userAction?method=deleteUser -> public ActionForward  
> deleteUser(ActionMapping m,ActionForm f,HttpServletRequest  
> req,HttpServletResponse res )
> 
> TIA,
> 
> Kunal
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

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