struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: [S2] Problem setting radio to default value from a Collection
Date Tue, 22 May 2007 23:45:53 GMT
I'm not quite clear what your code looks like, but based on what you say 
it sounds like you may be putting the wrong value in your 'answer' property.

     <s:radio name="answer" id="answer"
              list="game.question.answers"
              listKey="id" listValue="answer"
              onclick="...">

This iterates through the beans in the game.question.answers collection 
(C), and creates a radio button for each. The radio button value will be 
C[n].id, and its label will be C[n].answer, but your s:radio button 
references a property named 'answer'.

The property you reference in the 'name' attribute must contain a value 
drawn from C[n].id for all n -- in other words, that property should 
contain an answer ID.

If that's not clear or doesn't solve the problem, try posting the 
relevant bean and action code.

L.

Cesar Arevalo wrote:
> 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message