I like to display a dop-down select list and select an apropriate entry
from that list in an action:
This fills the list box:
<html:select property="expenseType">
<html:options collection="expenseTypes" property="typeCode"
labelProperty="typeDescription"/>
The expenseTypes is a Vector of the following class:
public class ExpenseType
{
long typeCode;
String typeDescription;
public ExpenseType()
{
}
public ExpenseType(long typeCode, String typeDescription)
{
super();
this.typeCode = typeCode;
this.typeDescription = typeDescription;
}
... setters and getters
}
In my Action class I usually use the following code to populate the form
with values from a business object:
PropertyUtils.setSimpleProperty(form, "expenseName", expense.getName());
...
How do I pre-select the correct entry in my drop-down list-box? In my
business object I have a value that matches the typeCode of the above
class but dispayed should be the typeDescription.
The collection is a vector, but I do not know the postition of the item
to select, I only have its value. So I cannot use
ProperyUtils.getIndexedProperty(..). But I can also not use
getMappedProperty() since a vector has no keys....
So how is this done with Vectors? Or should in general Hashtables be
taken for drop-down listboxes?
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]