Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts 2 s:radio tag

 
Bhaarat Sharma
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello

I have the following code in one of my struts 2 source files.

then I am creating radio buttons like this

now i do see two radio buttons, 'Apples' and 'Oranges' on the screen but what If i want to put different values for the two? I believe listKey attribute is used for that purpose but what can i Pass here? I am lost!

for example what If i want a value of "1" for Apples and "2" or Oranges? should I be making a list, just like list for Apples and Oranges, and put values in that list?

thanks for any help
 
Joachim Rohde
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a HashMap instead of an ArrayList.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When all else fails, read the documentation. It states clearly what the listKey and listValue attributes do, and what will happen if you specify a Map for the list attribute.
 
Bhaarat Sharma
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys, that worked.

But I had another question. is it possible to change the font of the items displayed by the radio tag. Further, is it possible to change the row color on every iteration?

before struts, I had something like this

<TR bgColor=#ffffff scope="row">
-show radio button here--

...

<TR bgColor = "#eeeee" scope="row>
-show another radio button here--

but now since s:radio tag iterates on its own ..I only have one TR tag.
 
Bhaarat Sharma
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to do this by modifying the radiomap.ftl template. works fine
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic