struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aamir Saalam" <asaa...@cisco.com>
Subject RE: loading the drop down...
Date Wed, 13 Feb 2002 00:08:07 GMT
You could fetch the name-value pairs in either a Map or your own name-value pair beans and
use the html:select in combination with
html:options to render list drop down.

For ex.

<%
  Map k = new Hashtable(); // <--  populated from the database
  k.put("country_id_1", "country name 1");
  k.put("country_id_2", "country name 2");
  k.put("country_id_3", "country name 3");

  pageContext.setAttribute("myMap", k, PageContext.PAGE_SCOPE);
%>

        <html:select property="countryID">
          <html:option value="">--select--</html:option>
          <bean:define id="ele" name="myMap" />
          <html:options collection="ele" property="key" labelProperty="value"/>
        </html:select>


--aamir


-----Original Message-----
From: sridhar ramalingam [mailto:sramalingam@fishmanconsulting.com]
Sent: Tuesday, February 12, 2002 3:54 PM
To: Struts Users Mailing List
Subject: loading the drop down...


Hello,
I'm very very new to Struts, I was developing a sample application using Struts. I then stumbled
in to a problem, here it is ...
I have to populate the down with a list of countries (say), the country list is in the database
with  a name value pair. I was
wondering, how am I going to populate the drop down inside my jsp page.

If any one could help me with a sample code, it would great.

Thanks a bunch!
Sridhar


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message