• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To iterate HashMap in struts

 
Lata Bagga
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
Lata Bagga
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic