Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts radio tag default value

 
Mathew Geraldo
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gurus:

I have a radio tag in my jsp as below

<s:radio name="radioName" value="2" list="#{'1':'A','2':B'}"/>

In my action class, I have a property 'radioName'.

First time the jsp page is loaded, the radio button defaults to 'B'. This is correct.
However, when the user makes a different selection and submits the page, the user selection has to be selected instead of the default value.
Can anyone please let me know how to achieve this?
Right now, no matter what the user selects, it is always defaulting to 'B'.
Thanks in advance!
 
Joe Ess
Bartender
Posts: 9320
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rather than setting the value in the JSP, you should be setting the value in the action. This allows you to choose between the default value the first time and the user selected value on subsequent views.
 
Mathew Geraldo
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joe, that worked!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic