Well as usual, although I spent a couple of hours trying to get it work,
as soon as I post to a mailing list I discover the answer....
So here is how I got it to work for future reference.

Created an Object like so:

public class RadioModel
{
        private int name;
        private String answer;

        public RadioModel()
        {
        }

        public RadioModel(int name, String answer)
        {
                this.name = name;
                this.answer = answer;
        }

        public int getName()
        {
                return name;
        }

        public void setName(int name)
        {
                this.name = name;
        }

        public String getAnswer()
        {
                return answer;
        }

        public void setAnswer(String answer)
        {
                this.answer = answer;
        }
}

Created a list of these:
List<RadioModel> options = new ArrayList<RadioModel>();
(then added the relevant values)

Then used this in the JSP:

<s:radio list="%{options}" listKey="name" listValue="answer"
name="question" theme="simple" />

Et voila.

-----Original Message-----
From: Dean Pullen [mailto:[EMAIL PROTECTED] 
Sent: 30 August 2007 16:48
To: user@struts.apache.org
Subject: Struts 2 Radio button - seperate value/label

Hi guys.

 

I can't work out via the Struts 2 documentation how to make a radio
button have a separate value and label from a given Map.

 

I'm trying:

<s:radio list="%{options}" name="questionOne"  theme="simple" />

 

Where 'options' is a HashMap<Integer, String>

 

What I get out on the JSP is one radio button only, with the following
text as the label:

{1=Yes, 2=No, 3=Maybe}

 

What I want is three radio buttons each with 1,2,3 as their values
respectively, and yes,no,maybe as their labels - retrieved from a Map.

 

How do I do this?

 

Thanks in advance.

 

 



Scanned by MailDefender - managed email security from intY -
www.maildefender.net

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to