You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rick Mann <rm...@latencyzero.com> on 2002/05/31 21:40:09 UTC

Arbitrary parameters in ActionMapping?

I've noticed a few people proposing solutions for various framework
limitations that use the "param" attribute of the <action> tag. Obviously,
only one parameter can reasonably be passed in this attribute.

Does it not make sense to add a nested tag for parameters? In the build of
Struts that I'm using, I haven't noticed anything like this. I was thinking
along the lines of something like this:

    <action path = "/someaction"
            type = "com.foo.bar.action.Action">

        <param name="param1" value="value1" />
        <param name="param2" value="value2" />
    </action>

Or, if you want to get XML-happy:

    <action path = "/someaction"
            type = "com.foo.bar.action.Action">

        <action-param>
            <param-name>param1</param-name>
            <param-value>value1</param-value>
        </action-param>
    </action>

but I don't know if that's strictly necessary (I'll let the smarter people
on the project decide).

In any event, in the code, you could write something like:

    String val1 = mapping.getParameter("param1");
    String val2 = mapping.getParameter("param2");

The method shouldn't even need to be named differently, as the existing
getParameter() takes no arguments. There would obviously be corresponding
setParameter(String) calls.

How does this seem?

-- 
Rick



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Arbitrary parameters in ActionMapping?

Posted by James Holmes <jh...@yahoo.com>.
Rick,

You can already accomplish what you are describing
with the current Struts architecture via
<set-property> elements.

<action ...>
  <set-property property="prop" value="val">
</action>

This will call the setProp(String value) method of
your action object with the "val" value.

The Struts Console makes it easy for setting these
properties on actions.

http://www.jamesholmes.com/struts/

-james
james@jamesholmes.com


--- Rick Mann <rm...@latencyzero.com> wrote:
> I've noticed a few people proposing solutions for
> various framework
> limitations that use the "param" attribute of the
> <action> tag. Obviously,
> only one parameter can reasonably be passed in this
> attribute.
> 
> Does it not make sense to add a nested tag for
> parameters? In the build of
> Struts that I'm using, I haven't noticed anything
> like this. I was thinking
> along the lines of something like this:
> 
>     <action path = "/someaction"
>             type = "com.foo.bar.action.Action">
> 
>         <param name="param1" value="value1" />
>         <param name="param2" value="value2" />
>     </action>
> 
> Or, if you want to get XML-happy:
> 
>     <action path = "/someaction"
>             type = "com.foo.bar.action.Action">
> 
>         <action-param>
>             <param-name>param1</param-name>
>             <param-value>value1</param-value>
>         </action-param>
>     </action>
> 
> but I don't know if that's strictly necessary (I'll
> let the smarter people
> on the project decide).
> 
> In any event, in the code, you could write something
> like:
> 
>     String val1 = mapping.getParameter("param1");
>     String val2 = mapping.getParameter("param2");
> 
> The method shouldn't even need to be named
> differently, as the existing
> getParameter() takes no arguments. There would
> obviously be corresponding
> setParameter(String) calls.
> 
> How does this seem?
> 
> -- 
> Rick
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>