struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jerry Jalenak" <Jerry.Jale...@LABONE.com>
Subject RE: Action Design Question
Date Fri, 26 Sep 2003 16:06:15 GMT
In the latest nightly builds there is a 'MappingDispatchAction' that does
this for you (takes the parameter directly).

Jerry Jalenak
Team Lead, Web Publishing
LabOne, Inc.
10101 Renner Blvd.
Lenexa, KS  66219
(913) 577-1496

jerry.jalenak@labone.com


> -----Original Message-----
> From: Nathan Rogers [mailto:nrogers@library.wisc.edu]
> Sent: Friday, September 26, 2003 11:00 AM
> To: Struts Users Mailing List
> Subject: Re: Action Design Question
> 
> 
> I don't know if this was the 'right' thing to do, but I extended 
> DispatchAction, overrode the execute method to use the 
> hardcoded value 
> rather than looking up a request parameter, and pass that along to 
> dispatchMethod.  My actions then inherit from this modified 
> class.  You 
> can safely cut out the lines with ServletContext if you don't 
> care about 
> logging invalid parameters.
> 
> Here's the source
> 
> /**
>     Overrides the execute method of DispatchAction so that rather
>     than use the parameter to determine which request parameter
>     contains the action to execute, it uses the parameter property
>     directly
> 
>     @param mapping ActionMapping
>     @param form Form associated with action
>     @param HttpServletRequest Current request object
>     @param HttpServletResponse Current response stream
> **/
> public ActionForward execute(ActionMapping mapping,
>                               ActionForm form,
> 			     HttpServletRequest request,
> 			     HttpServletResponse response)
>    throws Exception
>    {
>      String parameter = mapping.getParameter();
>      if (parameter == null) {
> 	String error = "Could not locate the requested forward";
> 	ServletContext context = getServlet().getServletContext();
> 	ServletContextWriter output = new ServletContextWriter(context);
> 	output.write(error);
> 	output.flush();
> 	
>  
> response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERRO
> R, error);
>          return null;
>      }
> 
>    return dispatchMethod(mapping, form, request, response, parameter);
>    }
> 
> -- 
> Nathan Rogers
> Library Technology Group
> 312F Memorial Library
> 728 State Street
> 261-1409
> 
> Graham Lounder wrote:
> 
> > Hey all,
> > 
> > After reading the "[Poll] action mappings" thread, I now 
> have a couple of
> > design questions.  I've got a lot of actions right  now and 
> I'd like to
> > group related functionality into one action.  I'm thinking 
> of extending the
> > DispatchAction and creating functions to
> > search/view/create/update/delete/load my objects.  I'd like 
> to create
> > separate action mappings for each function.  My question is, can I
> > "hardcode" my dispatch parameter in the action mapping or 
> do I have to send
> > it in ever request from the page?
> > 
> > Thanks in advance,
> > Graham
> > 
> > 
> ==============================================================
> ==========
> > Graham Lounder - Java Developer
> > CARIS Spatial Components Division
> > graham.lounder@caris.com
> > Phone:  (506) 458-8533
> > Fax:    (506) 459-3849
> > 
> ==============================================================
> ==========
> > NO BINDING CONTRACT WILL RESULT FROM THIS EMAIL UNTIL SUCH TIME
> > AS A WRITTEN DOCUMENT IS SIGNED ON BEHALF OF THE COMPANY.
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > 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
> 
> 

This transmission (and any information attached to it) may be confidential and is intended
solely for the use of the individual or entity to which it is addressed. If you are not the
intended recipient or the person responsible for delivering the transmission to the intended
recipient, be advised that you have received this transmission in error and that any use,
dissemination, forwarding, printing, or copying of this information is strictly prohibited.
If you have received this transmission in error, please immediately notify LabOne at the following
email address: securityincidentreporting@labone.com



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


Mime
View raw message