You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joerg Friedrich <Jo...@marconi.com> on 2001/05/15 13:32:47 UTC
Using the struts tag
Hi,
does anybody have some short example code on how to use a Java Bean collection
with the <html:options> tag? Thanks!
Best regards,
Joerg Friedrich
Re: Using the struts tag
Posted by Scott Walter <tx...@yahoo.com>.
Hi,
I have a situation where I want to load a list of the
database tables into a dropdown at server startup and
then use the list on a jsp page.
This is how I did it:
Step 1. Load the table into a collection and store it
as a session variable:
public static void loadTableNames(Connection conn,
ServletContext context) throws SQLException {
ArrayList tempList = new ArrayList();
DatabaseMetaData meta = conn.getMetaData();
ResultSet rs = meta.getTables(null, null, "%",
null);
while (rs.next()) {
String tableName = rs.getString("TABLE_NAME");
tempList.add(new LabelValueBean(tableName,
tableName));
}
context.setAttribute("sys_tables", tempList);
}
Step 2. On a JSP Page I use the <option> tag
<struthtml:options collection="sys_tables"
property="value" labelProperty="label"/>
scott.
--- Joerg Friedrich <Jo...@marconi.com>
wrote:
>
>
> Hi,
>
> does anybody have some short example code on how to
> use a Java Bean collection
> with the <html:options> tag? Thanks!
>
> Best regards,
>
> Joerg Friedrich
>
>
=====
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Scott
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/