Ashish Kulkarni wrote:
Yes, totally possible. Here are some snippets. :-)Hi How do i display a drop down box from hashtable data here is my form definiation <form-bean dynamic="true" name="loginForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="as400list" type="java.util.Hashtable" /> </form-bean>
in my html i define
<html:form action="/login" focus="userId"
method="post" style="margin:0px;" >
// logic to display html:select with html:option tag
</html:form>
This is what you'd have in your JSP
<html:select property="propertyname" size="1">
<html:options collection="beanname" property="value" labelProperty="label"/>
</html:select><br>
And this is how I build the list in my classes: First my Action:
ArrayList trusts = AssetData.getTrusts(
getDataSource(request,"trustmaster"), errors); if ((assets == null) || (codes == null) || (trusts == null)) {
errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("error.resultset.null"));
} else {
// Put our results set in a bean in the session
session.setAttribute("assets", assets);
session.setAttribute("codes", codes);
session.setAttribute("trusts", trusts);
}
Now my Data: public static ArrayList getTrusts( final DataSource dataSource, final ActionErrors errors) throws Exception {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ArrayList trusts = new ArrayList();try {
conn = dataSource.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from trusts;");
// While there are results from our query
// create the codes bean with the proper
// values from the database.
while (rs.next()) {
trusts.add(
new LabelValueBean(
rs.getString("trust_name"),
rs.getString("code")));
}
} finally {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
} return trusts; }
Hopefully this helps. Brandon
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

