wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts radio tag default value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts radio tag default value" Watch "Struts radio tag default value" New topic
Author

Struts radio tag default value

Mathew Geraldo
Greenhorn

Joined: Mar 27, 2013
Posts: 19
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

Joined: Oct 29, 2001
Posts: 8843
    
    7

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.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Mathew Geraldo
Greenhorn

Joined: Mar 27, 2013
Posts: 19
Thanks Joe, that worked!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts radio tag default value
 
Similar Threads
Prepopulating Radio buttons in JSP
HttpServlet Request getParameter automatic converting
Struts 1.1: html:radio issues
HttpServlet Request getParameter automatic converting
Struts2 select default selection