Hello,
I am finally able to show a select list in my jsp page. My workflow was to
create a "unvalidated" bean, go to the action, perform a db query, and create
the data for the select list.
My bean name is: 'usersbean'.
Here is what I am doing in the action, I have created a collection, and a
"selected" item. Or at least I thought it would show a selected item.
Action class
private Collection beanCollection = null;
private String[] beanCollectionSelect = new String[] { "17" };
public Collection getBeanCollection() {
return (beanCollection);
}
public void setBeanCollection(RowEnum re) {
Vector entries = new Vector();
boolean gotString = false;
while (re.next()) {
if (!gotString) {
String setSelect = re.getString("user_id");
beanCollectionSelect = new String[] { setSelect };
gotString = true;
}
entries.add(new LabelValueBean(re.getString("firstname") + " " +
re.getString("lastname") + " - " + re.getString("username"),
re.getString("user_id")));
}
beanCollection = entries;
}
public String[] getBeanCollectionSelect() {
return (this.beanCollectionSelect);
}
public void setBeanCollectionSelect(String beanCollectionSelect[]) {
System.out.println("Setting the bean collection with id of =" +
beanCollectionSelect[0]);
this.beanCollectionSelect = beanCollectionSelect;
}
Now in my jsp page I am just using this:
<html:select property="beanCollectionSelect" size="10" multiple="false">
<html:optionsCollection name="usersbean" property="beanCollection" />
</html:select>
And it displays a select list of size 10. But for whatever reason, I cannot get
the item "17" which is an "option value" in the select list to be highlighted.
Also, I know I am using a String[] for multiple, and I am only using single.
Any help.
Scott K Purcell | Developer | VERTIS |
555 Washington Ave. 4th Floor | St. Louis, MO 63101 |
314.588.0720 Ext:1320 | [EMAIL PROTECTED] | http://www.vertisinc.com
<http://www.vertisinc.com/>
Vertis is the premier provider of targeted advertising, media, and
marketing services that drive consumers to marketers more effectively.