struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Husted <hus...@apache.org>
Subject Re: ActionMapping parameter
Date Tue, 04 Sep 2001 16:42:17 GMT
So far, we've had three suggestions about what to do about this:

1. Use named parameters instead of a single parameter (as just
mentioned)
2. Use parameter as the name of a property file or other resource where
the actual parameters are kept. 
3. Add methods to ActionMappings to retrieve parameters as if parameter
were a query string.

So in the last case, you could set parameter to be something like 

parameter="form=input+action=update" 

and then retrieve it using methods like 

String form = mapping.getParameter("form"); 

and still keep  

String parameter = mapping.getParameter()

to retrieve the String as is (or maybe just the first parameter).

This has the virtue of being trival to implement, and jives with the way
Forwards have to be coded. 

A quick and easy way to do this starting now, would be to use the
HttpUtils class

http://java.sun.com/j2ee/tutorial/api/javax/servlet/http/HttpUtils.html

and do something like 

--

HashTable parameters =
HttpUtils.parseQueryString(mappings.getParameter());
String form = (String) parameters.get("form"); 

--

Anyone want to give a implementation of doing this within ActionMappings
a whirl? I'd be thinking we'd want all the same parameter methods from
ServletRequest

http://java.sun.com/j2ee/tutorial/api/javax/servlet/ServletRequest.html

Another idea would be to just implement getParameterMap() in
ActionMappings, since HttpUtils is deprecated in Servlet 2.3 ;-(, and
leave it at that.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/about/struts/


Ernest Jones wrote:
> 
> I wanted some feedback on a feature request before I submit it.
> 
> In the ActionMapping api you can only get one nameless config parameter
> (public String getParameter()).  I would find it useful if I could specify
> any number of named parameters (public String getParameter(String key)).
> The xml in the struts-config file could look like:
> 
> <action path="/myPath"  type="com.mycompany.actions.DoSomething">
>    <parameter name="paramName" value="paramValue"/>
>    <parameter name="paramName2" value="paramValue2"/>
>     ...
>   <forward name="success" path="/success.jsp" />
>  </action>
> 
> To maintain backwards compatability (if you really wanted to) you could keep
> the old parameter attribute and function.
> 
> Thoughts? Comments?

Mime
View raw message