You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Dudley Butt@i-Commerce" <Du...@za.didata.com> on 2001/06/04 20:07:14 UTC

RE: Any Hashmap examples used in jsp page? - THANX!!!

Hi all, 

I just want to thank everyone for their great responses, I really appreciate
all the help.....GREAT THANX

-----Original Message-----
From: Shamdasani Nimmi-ANS004 [mailto:ANS004@motorola.com]
Sent: Monday, June 04, 2001 6:02 PM
To: 'struts-user@jakarta.apache.org'
Subject: RE: Any Hashmap examples used in jsp page?


Steve,

This is how I used a HashMap in a jsp:

<logic:iterate id="item" name="user_list" property="userList" >

<TR>
<TD><bean:write name="item" property="key"/></TD>
<TD><bean:write name="item" property="value"/></TD>
</TR>

</logic:iterate>

getUserList() method in my user_list bean returns a HashMap.

Hope this helps.

-Nimmi


-----Original Message-----
From: Steve A Drake [mailto:sad@comet.ucar.edu]
Sent: Friday, June 01, 2001 5:58 PM
To: struts-user@jakarta.apache.org
Subject: RE: Any Hashmap examples used in jsp page?


 Hi Jon. I'm having a similar problem as Dudley with a HashMap. I tried
playing around with your example but couldn't get it to work within the
context of what I'm doing. Perhaps another example would help. For
example, I have a scriptlet that looks something like:

 fee.fie.fo.sql.ResultSetBean rsb =
        (fee.fie.fo.sql.ResultSetBean) request.getAttribute("resultBean");
 java.util.HashMap hm = rsb.getProperties();
 String foobar = (String) hm.get("foobar");
 out.println("foobar = " + foobar);


So, the ResultSetBean contains a HashMap as a property. I get a reference
to the HashMap and then can extract a value with a key as input. Any ideas
on the syntax of doing this with "bean" tags? TIA.



On Fri, 1 Jun 2001, Jon.Ridgway wrote:

> Hi Dudley,
>
> See code sample below. The type in the iterate tag must be as shown, you
> will then need to use a bean define to put your 'value' into the page
> context and cast it to whatever type you have placed in your HashMap
value.
>
> Hope this helps,
>
> Jon.
>
> <logic:iterate id="list" name="gallery" property="artifacts"
> type="java.util.Map.Entry">
>
> 	  <bean:define id="artifact" name="list" property="value"
> type="net.itwa.model.artifact.IArtifact"/>
>
> 	  <bean:write name="artifact" property="description"/>
>
> </logic:iterate>
>
>
> -----Original Message-----
> From: Dudley Butt@i-Commerce [mailto:Dudley.Butt@za.didata.com]
> Sent: 01 June 2001 10:34
> To: struts-user@jakarta.apache.org
> Subject: Any Hashmap examples used in jsp page?
>
> Hi all,
>
> Could anyone please point me to where i can find some examples using
> hashmaps in a jsp with struts...
> Instead of using a whole bunch of logic equal tags all the time, i need a
> way to evaluate a collection, looking for a specific key value, then show
or
> hide the relevant input boxes on my jsp..
> any help...please!!!???
>

-----------------------------------------------------------
Steve Drake                            sad@comet.ucar.edu
UCAR / COMET                           (303) 497 - 8496
PO Box 3000
Boulder, CO  80307-3000