Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

To iterate HashMap in struts

 
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?
 
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 ]
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic