You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ganendran Kumaraswamy <Ga...@eRunway.com> on 2001/08/15 10:45:12 UTC

Displaying a hashmap through html:options

I have created and set a hashmap called "hm" in the request object in my
action class.  Action class forwards it to a JSP page. In the JSP page, I
have the following line to get the bean into the page.
 
<bean:define id="hmap" name="hm" scope="request" type="java.util.HashMap"/>
 
I am trying to populate the options tag using the data in the hashmap. I
want the keys of the hashmap to be the value of the <option> tag in html and
the value of the hashmap to be the displayed text.
 
Currently I have something like,
 
<html:select property="singleSelect" size="6">
<html:options collection="hmap" property="hmap" labelProperty="hmap" />
</html:select>
 
This doesnt seem to work.  Any ideas ?

 

Re: Displaying a hashmap through html:options

Posted by Will Jaynes <wj...@mediaone.net>.
The options tag doesn't permit the use of a Hashmap. A Hashmap is not actually a
Collection, since it doesn't implement the Collection interface. Perhaps this
utility is a possible enhancement for the options tag.

----- Original Message -----
From: "Ganendran Kumaraswamy" <Ga...@eRunway.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, August 15, 2001 4:45 AM
Subject: Displaying a hashmap through html:options


I have created and set a hashmap called "hm" in the request object in my
action class.  Action class forwards it to a JSP page. In the JSP page, I
have the following line to get the bean into the page.

<bean:define id="hmap" name="hm" scope="request" type="java.util.HashMap"/>

I am trying to populate the options tag using the data in the hashmap. I
want the keys of the hashmap to be the value of the <option> tag in html and
the value of the hashmap to be the displayed text.

Currently I have something like,

<html:select property="singleSelect" size="6">
<html:options collection="hmap" property="hmap" labelProperty="hmap" />
</html:select>

This doesnt seem to work.  Any ideas ?