Michael,

I just use the collection and property value on my html:options, and Struts does
the rest!

ie <html:options collection="..." property="..."> (and you can use the
labelProperty if you want too)

Check out the documentation on it...

Dave





"Michael Skariah" <[EMAIL PROTECTED]> on 06/26/2001
12:50:35 PM

Please respond to [EMAIL PROTECTED]; Please
      respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:    (bcc: David Hay/Lex/Lexmark)
Subject:  Minimizing the code in JSP file......by removing the for loop



Hello all,
I am new to Struts and was experimenting the various HTML tags. I was trying
to improve the code below. Could anyone tell me how I can achieve the same
functionality of filling the select block, but by removing the "for" loop
from this code(I mean just by filling values with a list).
Thanks to all for the help.
-Mike.

---------------------------------------------
<html:form action="result.do" method="post" focus="accountNo">
<jsp:useBean id="codes" scope="request" class="com.test.mytest.TestAction"/>
<%
     Hashtable ht = codes.getCodes();
%>

<bean:message key="prompt.accountnumber"/>
<html:select name="accountNo" align="center" size="1" value="">
<html:options>
<%
     List myList = (List)ht.get("AccountNo");
     if(myList != null)
     {
          for(ListIterator li=myList.listIterator(); li.hasNext();)
          {
%>
<option>
<%= (String)li.next() %>
<%
          } // for
     }
     else
     {
%>
<html:options>
<%= "No matching data" %>
<%
     }
%>
</html:select>
</html:form>
---------------------------------------------







Reply via email to