You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joanne L Corless <jc...@csc.com> on 2003/10/15 16:24:10 UTC
Passing multiple parameters from a jsp page to action class - using JSTL
- How?
Hi,
Spurred on with my recent success regarding passing parameters on html:link
I now want to pass 2 parameters into the action class from the jsp. I
realise I have to create a java.util.map to do this but how can I combine
this with using the JSTL?
i.e. Currently I am passing in one parameter
<html:link action="/changePage"
paramId="pageName"
paramName="topMenuItem"
paramProperty="menuItemName"/>
which equates on rendering to an <a href
="<appcontext>/changePage?pageName=menuItemNameValue"></a>
Now I need to end up with a <a href
="<appcontext>/changePage?pageName=menuItemNameValue&menuBlock=menuBlockValue"></a>.
Which I am assuming needs the html:link to be
<html:link action="/changePage"
name="paramMap"/>
Therefore how using the JSTL can I instantiate a java.util.map and populate
it? It is simple enough to do in a java scriptlet
<% java.util.Map paramMap = new HashMap();
paramMap.put("pageName", "menuItemNameValue");
paramMap.put("menuBlock","menuBlockValue");
%>
but I am trying to follow best practices and use the tag libraries
Regards
Joanne Corless
CSC Computer Sciences Limited
( Office +44 (0)1772 318025
( Mobile +44 (0)7767 656588
* email jcorless@csc.com
Based at: CSC, Alliance House, Library Road, Chorley, Lancs, PR6 7EN
CSC Computer Sciences Limited: Registered in England, No. 963578.
Registered office: Royal Pavilion, Wellesley Road, Aldershot, Hampshire,
GU11 1PZ.
----------------------------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.
----------------------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Passing multiple parameters from a jsp page to action class - using JSTL - How?
Posted by Kris Schneider <kr...@dotech.com>.
<jsp:useBean id="paramMap" class="java.util.HashMap">
<c:set target="${paramMap}" property="pageName" value="menuItemNameValue"/>
<c:set target="${paramMap}" property="menuBlock" value="menuBlockValue"/>
</jsp:useBean>
Quoting Joanne L Corless <jc...@csc.com>:
> Hi,
>
> Spurred on with my recent success regarding passing parameters on html:link
> I now want to pass 2 parameters into the action class from the jsp. I
> realise I have to create a java.util.map to do this but how can I combine
> this with using the JSTL?
>
> i.e. Currently I am passing in one parameter
>
> <html:link action="/changePage"
> paramId="pageName"
> paramName="topMenuItem"
> paramProperty="menuItemName"/>
>
> which equates on rendering to an <a href
> ="<appcontext>/changePage?pageName=menuItemNameValue"></a>
>
> Now I need to end up with a <a href
>
="<appcontext>/changePage?pageName=menuItemNameValue&menuBlock=menuBlockValue"></a>.
> Which I am assuming needs the html:link to be
>
> <html:link action="/changePage"
> name="paramMap"/>
>
> Therefore how using the JSTL can I instantiate a java.util.map and populate
> it? It is simple enough to do in a java scriptlet
>
> <% java.util.Map paramMap = new HashMap();
> paramMap.put("pageName", "menuItemNameValue");
> paramMap.put("menuBlock","menuBlockValue");
> %>
>
> but I am trying to follow best practices and use the tag libraries
>
> Regards
>
> Joanne Corless
>
> CSC Computer Sciences Limited
> ( Office +44 (0)1772 318025
> ( Mobile +44 (0)7767 656588
> * email jcorless@csc.com
>
>
> Based at: CSC, Alliance House, Library Road, Chorley, Lancs, PR6 7EN
> CSC Computer Sciences Limited: Registered in England, No. 963578.
> Registered office: Royal Pavilion, Wellesley Road, Aldershot, Hampshire,
> GU11 1PZ.
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org