ObjectChoiceField categoryChoiceField = new ObjectChoiceField("", categories, 0, Field.FIELD_LEFT);
categoryChoiceField.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
if (context == ChoiceField.CONTEXT_CHANGE_OPTION) {
ChoiceField choiceField = (ChoiceField) field;
int index = choiceField.getSelectedIndex();
if (index >= 0) {
Category category = (Category) choiceField.getChoice(index);
displayCategory(category);
}
}
}
});