struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Husted <>
Subject Re: Feature request (with code) for ActionMapping/ActionConfig
Date Tue, 10 Sep 2002 09:29:14 GMT
You can actually do this now using the generic "set-property" element, 
supported by the Digester.

 >     <action path="/index" type="pl.wwtech.shared.struts.IndexAction">
 >       <set-property property="test" value="value"/>
 >       <forward name="default" path="page.index"/>
 >     </action>

In Struts 1.1,  you have to set the classname attribute for the 
ActionMapping to use your subclass. In Struts 1.0.x, there are 
corresponding init-params for the ActionServlet.

This works with all the configuration objects, like ActionForwards.

I must say you certainly have the right attitude =:-) Please keep 
looking for other features we may be missing ...


Deacon Marcus wrote:

> Hi,
> I was wondering why there's no way to assign multiple parameters to
> action mappings, and came with the following solution. Basically, the
> idea is to have something like: "
>     <action path="/index" type="pl.wwtech.shared.struts.IndexAction">
>       <set-parameter name="test" value="value"/>
>       <forward name="default" path="page.index"/>
>     </action>
> "
> in struts.xml, then to be able to use it like:
> " System.out.println(mapping.getParameter("test","default-value"));
> System.out.println(mapping.getParameter("test"));
> "
> from Action subclass. Additionaly, getParameter returns value of the
> same type (limited) as default value, so it is possible to have: " float
> f = mapping.getParameter("test-float",0.0);
> long l = mapping.getParameter("test-long",0);
> "
> It also implements a basic getAttribute / setAttribute scheme to allow
> for "mapping-scope" runtime-only attributes. Of course it can easily be
> modified (I volunteer if you want it) to support initialization from
> xml. I needed something like that on numerous occasions so I included it
> here.
> I have attached some code based on 1.1b2 - please review it and let me
> know if you want me to post the whole thing. I'm sure it's stable, we're
> already using it in a number of production projects. To quickly find all
> modified fragments search for "MMM" (case-sensitive). I'm not sure about
> the configuration code - I don't use the Digester normally, I know it
> works (heavily tested) but I'm not sure if it's the best (or most
> recommended) way to implement this. There's no freeze-checks because
> only name-value pairs are stored, so once added the parameters are
> effectively immutable (by design). Also, comments are lacking because
> the code is so basic they're not really needed. "//MMM" in various
> places can (should) of course be removed - my team use triple m as a
> kind of tag. Please let me know what you think - I need this (or
> similar) capability in Struts, and I would be gratefull if you could
> include it it nightlies or next beta. Greetings,
>      Sebastian P. Markiewicz, WWTech (aka deacon Marcus)
>      tel +48 602 102750
>      fax +48 602 145786
> ------------------------------------------------------------------------
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

Ted Husted, Husted dot Com, Fairport NY US
co-author, Java Web Development with Struts
Order it today:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message