File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes struts 2 s:radio tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 s:radio tag" Watch "struts 2 s:radio tag" New topic

struts 2 s:radio tag

Bhaarat Sharma
Ranch Hand

Joined: Jun 04, 2007
Posts: 96

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

Joined: Nov 27, 2006
Posts: 430

Use a HashMap instead of an ArrayList.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.

Consultant, Sima Solutions
Bhaarat Sharma
Ranch Hand

Joined: Jun 04, 2007
Posts: 96
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

Joined: Jun 04, 2007
Posts: 96
I was able to do this by modifying the radiomap.ftl template. works fine
I agree. Here's the link:
subject: struts 2 s:radio tag
It's not a secret anymore!