________________________________
From: Wim De Smet <krom...@gmail.com>
To: Struts Users Mailing List <user@struts.apache.org>
Sent: Mon, October 12, 2009 3:20:49 AM
Subject: Re: using a map of parameters with the s:url tag

On Mon, Oct 12, 2009 at 12:06 PM, Tommy Pham <tommy...@yahoo.com> wrote:
> ________________________________
> From: Wim De Smet <krom...@gmail.com>
> To: Struts Users Mailing List <user@struts.apache.org>
> Sent: Mon, October 12, 2009 2:23:29 AM
> Subject: using a map of parameters with the s:url tag
>
> Hi all,
>
> I'm using struts 2.1.x. Given a Map<String,String> called parameters I
> want to construct an URL as follows:
> <s:url id="testUrl" action="test">
>  <s:iterator value="parameters">
>    <s:param name="%{key}" value="value" />
>  </s:iterator>
> </s:url>
>
> Unfortunately the nested iterator seems to hide the parameter tag from
> the enveloping url tag? I've verified that it's indeed iterating and
> that the entrySet is available with the two values, key and value. But
> I can't seem to use this to construct the URL. Is there no way to do
> this? Maybe a workaround?
>
> regards,
> Wim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>
> Hi Wim,
>
> Did you want to generate a new URL including all the current parameters?
>
> http://struts.apache.org/2.1.8/docs/url.html
>
> <s:url id="testUrl" action="test" includeParams="true" />

No I'm trying to generate them dynamically. So in the action I'd do
the following:
Map<String,String> params = new HashMap<String,String>();
...
params.put(somename, "somevalue");

Then use that map in the JSP to set the parameters. These parameters
are not set on the current page so including them with includeParams
won't help me.

regards,
Wim

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

Try this then:

<s:url id="testUrl" action="test">
  <s:iterator value="parameters">
   <s:param name="%{#key}" value="#value" />
  </s:iterator>
</s:url>

or 

<s:url id="testUrl" action="test">
  <s:iterator var="param" value="parameters">
   <s:param name="%{#param.key}" value="#param.value" />
  </s:iterator>
</s:url>

Regards,
Tommy

Reply via email to