aspose file tools*
The moose likes Struts and the fly likes How to hashmap with html:link to transfer data in STRUTS? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to hashmap with html:link to transfer data in STRUTS?" Watch "How to hashmap with html:link to transfer data in STRUTS?" New topic
Author

How to hashmap with html:link to transfer data in STRUTS?

Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
Hi,
I am developing my web Application using struts.
In one of my page I want to transfer some bulk of data through querystring (by attaching it to URL) to another page.
I am doing it as follows:-
<jsp:useBean id="paramsMap" class="java.util.HashMap" scope="request" />
<c:set target="${paramsMap}" property="partid" value="${featuredItems.partid}" />
<c:set target="${paramsMap}" property="partno" value="${featuredItems.partid}"/>
<c:set target="${paramsMap}" property="weight" value="${featuredItems.unitweight}"/>
<c:set target="${paramsMap}" property="moq" value="${featuredItems.moq}"/>
<c:set target="${paramsMap}" property="price" value="${featuredItems.listprice}"/>
<c:set target="${paramsMap}" property="desc" value="${featuredItems.description}"/> <html:link page="/addtocartpage.do" paramId="fpartid" paramName="paramsMap">Add to Cart</html:link>
Now when user Clicks on "Add to Cart" link on this page he gets transfered to page corresponding to "addtocartpage.do" action.
Now on that page I want to extract individual parameters from my Hashmap received by querystring. Although I am able to view entire hashmap content onto this second page using:-
<%=request.getParameter("fpartid").toString()%> & I am getting output as
{partno=P0000302, moq=1.0, partid=P0000302, price=487.5, desc=LINER, HONEYCHROMED (NEW)}

But I want to retrieve individual parameter values from this hashmap onto my page. How to do that?

Also is it the correct way that I am using for transferring data through hashmap above?
Please help me.
Thanx in advance.
Prash


********Deserve Before You Desire********
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
I think you are using the hashmap correctly (although I'm not 100% sure).

You should use a form for your addcarttopage action. When values come in a query string, they will get populated in the form automatically before getting to your action.
Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
thanx for ur reply. but can u please answer my another qoestion :-
"But I want to retrieve individual parameter values from this hashmap onto my page. How to do that?"

thanx.
pras
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
I'm not at all familiar with JSTL, but can't you just do this:
<cut value="${featuredItems.partid}"/>?

Also, I think your link should look like this:
<html:link page="/addtocartpage.do" name="paramsMap"/>
[ July 06, 2006: Message edited by: Dom Lassy ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to hashmap with html:link to transfer data in STRUTS?