Here's a sample from a form that uses states.  The states are generated from
a class to keep less java on the jsp page, but you can see how the options
are generated and set to selected if they match the value in the bean.



<select tabindex="7" name="State">
                            <option value="" selected>Choose a State
</option>
                            <%State[] states = State.getAll();
                                  for(int i=0; i<states.length; i++){
                                    String ab = states[i].getAbbreviation();
                                    String nm = states[i].getName();%>
                            <option value=<%=ab%>
<%if(ab.equals(setupBean.getAgentState())){%>selected<%}%>><%=nm%></option>
                            <%}%>
                          </select>


Hope that helps!

Brandon

-----Original Message-----
From: Denise Mangano [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 02, 2003 3:48 PM
To: 'Tomcat Users List'
Subject: Easy question - Java Beans


Just curious if anyone knows how to use bean properties so that on a retry
of a form, the previously selected item in a select list is maintained if
validated. For example, for "Select Your State".  If I select NY, but
something else on my form is wrong, when Retry.jsp is brought up, the State
select box is still on "NY".

Is this possible?  I am currently using the same code as I do for the text
fields, but the state is not being maintained.

Thanks!

Denise Mangano
Help Desk Analyst
Complus Data Innovations, Inc.


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to