> -----Original Message----- > From: Ralph Einfeldt [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 10, 2003 3:24 AM > To: Tomcat Users List > Subject: RE: Java Bean Scope questions (a lengthy one) > [getting desperate] > > > > As already was pointed out you have to reinitialise > sindex before you run the while loop. > > There at least to options to do that: > - define a method like initStateList() and call it > before you enter the loop. > - reset the value in hasMoreStates() when false is returned
Personally, I'd prefer a third option: Move the state list iteration into another class (say, "StateListIterator") and put a "getStateListIterator" method on the form bean that returns a new instance of that class each time it's called. Then get a new iterator each time the page is called. That's more in line with how collection iterators work in the JDK, and I think it's just easier to understand in general. -- Tim Moore / Blackboard Inc. / Software Engineer 1899 L Street, NW / 5th Floor / Washington, DC 20036 Phone 202-463-4860 ext. 258 / Fax 202-463-4863 > > > -----Original Message----- > > From: Denise Mangano [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, January 09, 2003 10:00 PM > > To: 'Tomcat Users List' > > Subject: RE: Java Bean Scope questions (a lengthy one) [getting > > desperate] > > > > <% while(formBean.hasMoreStates()) { %> > > <option value=<%= formBean.getStateList()%>><%= > > formBean.getStateList()%></option> > > <% } > > > > > public boolean hasMoreStates() > > { > > if (sindex < stateArray.length) > > return true; > > else > > return false; > > } > > > //int sindex=-1; declared at beginning of class > > public String getStateList() > > { > > sindex++; > > String stemp = stateArray[sindex]; > > return stemp; > > } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
