aspose file tools*
The moose likes Struts and the fly likes To iterate HashMap in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "To iterate HashMap in struts" Watch "To iterate HashMap in struts" New topic
Author

To iterate HashMap in struts

Lata Bagga
Ranch Hand

Joined: Jun 13, 2007
Posts: 35
Hello friends,

I am new to Struts.I want to iterate over the Hashmap and save its "key" in the radio button as:


Here AddressMap is the HashMap.
What should I give the value to the "value" attribute of the radio button so that I can have the "key" of HashMap i.e AddressMap or should I use <html:radio> tag. Could anyone please help me out?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864

Just a couple of notes: It's best to use the <html:radio> tag because it will show the correct button as selected if you have pre-selected values. Also, providing a body for the <html:radio> tag is the same as specifying a value attribute. Also, it's not a good idea to specify the same name for both the name and id attribute of a <logic:iterate> tag.
[ June 24, 2008: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Lata Bagga
Ranch Hand

Joined: Jun 13, 2007
Posts: 35
Thanks Merril for the solution. But I am getting an error in jsp saying that "value" attribute is required. Please help me out, I need it urgently.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
What I told you about the body substituting for a value attribute is correct for most other Struts html tags, but apparently not for html:radio. Sorry about that. Fortunately, though, html:radio has an idName attribute that can be used to get a bean exposed by a logic:iterate tag. Example:

[ June 25, 2008: Message edited by: Merrill Higginson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: To iterate HashMap in struts