Worked around this, putting this piece of code before
the end of my body tag
in the jsp page:

<s:if test="task == 'showAnswer'">
        <SCRIPT type="text/javascript">
                document.getElementById('answer<s:property
value="answer"/>').checked=true;
        </SCRIPT>
</s:if>

However I don't like it. According to the
documentation the radio should
check the default to the answer value, because it has
the same name as the
property in my action, but it is not working this way.
How can you set a
default value for a radio tag if my list is a
Collection?

Thanks
-Cesar

-----Original Message-----
From: Cesar Arevalo [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 22, 2007 2:00 PM
To: 'Struts Users Mailing List'
Subject: [S2] Problem setting radio to default value
from a Collection


Hi All,

 

I have a jsp with a radio tag setup like so:

 

<s:radio name="answer"
id="answer"list="game.question.answers"
listKey="id"listValue="answer"onclick="document.getElementById('CheckAnswer'
).submit()">

< /s:radio>

 

What I display in the radio buttons are answers, once
the userclicks on an
answer the form is submitted, my action retrieves the
correctanswer and puts
it in both an id and an answer property defined in the
sameaction. Now, what
I want to show to the user is the correct answer after
heselects any answer,
even if it&#8217;s the correct one. However even
though I havesetup my
action with an id and answer property, the radio
button does notdefault to
the value I am putting in those properties. The
documentationspecifies that
this works for maps, so does radio buttons work the
same way fora
Collection? Or how do they work for setting checked
options using a
Collection?Can anyone help me?

 

Thanks

-Cesar



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

Reply via email to