This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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: 8718
    
    6

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
HttpServlet Request getParameter automatic converting
Struts 1.1: html:radio issues
Struts2 select default selection
Prepopulating Radio buttons in JSP
HttpServlet Request getParameter automatic converting