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