Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping radio selection 1

Status
Not open for further replies.

dreampolice

Technical User
Dec 20, 2006
85
US
How do I keep Radio button values and not lose them after a Form is submitted? I have no problem keeping text values where a form is submitted and if there is a validation issue with the text value it takes me back to the Form and shows the Form text value that was submitted. With Radio buttons it clears the Form Radio selection.

JavaBean:
Code:
public void setNotify(String n) {
    notify=n;
  }
 public String getNotify() {
    return notify;
  }


Form in JSP:
Code:
<jsp:useBean id="formHandler" class="Concord.FormBean" scope="request"/>
 
<form action="process.jsp" method=post>
....
Yes <input type="radio" name="notify" value="Yes" <jsp:getProperty name="formHandler" property="notify" /> >   <br>      
No <input type="radio" name="notify" value="No"  <jsp:getProperty name="formHandler" property="notify" /> >

Please advise.
 
First off, this probably belongs in the J2EE forum. I think what you might need to do is something like this:

Code:
<jsp:useBean id="formHandler" class="Concord.FormBean" scope="request"/>
 
<form action="process.jsp" method=post>
....
Yes <input type="radio" name="notify" value="Yes" <c:if test="${formHandler.notify equals 'Yes'}">selected</c:if> >   <br>      
No <input type="radio" name="notify" value="No"  <c:if test="${formHandler.notify equals 'No'}">selected</c:if> >

Let me know if that works
 
Thanks, I am using Java 1.4 in Tomcat 4.1.3 container without any EL or JSTL.

How would I do the same with Scriptlet?
 
how about this

Code:
Yes <input type="radio" name="notify" value="Yes" <%if ("Yes".equals(request.getParameter("notify"))){ %> Selected <% } %> > <br>      
No <input type="radio" name="notify" value="No"  <%if ("No".equals(request.getParameter("notify"))) { %> Selected <% } %> >
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top