PDA

View Full Version : ComboBox - selection always empty



rian.k
10 Sep 2009, 5:53 AM
Hi,

I'm want to add a SelectionChangeListener to my ComboBox,
but when I click on an item in the persented list, the selection
in the handler is always empty. Can you spot my mistake?



class User implements BeanModelTag {
...
}

final ComboBox<User> combo = new ComboBox<User>();

final BasePagingLoader<PagingLoadResult<B>> loader
= new BasePagingLoader<PagingLoadResult<B>>(
proxy, new BeanModelReader());
loader.setRemoteSort(true);

final ListStore<BeanModel> store = new ListStore<BeanModel>(loader);

combo.setForceSelection(true);
combo.setItemSelector(divClass);
combo.setTemplate(template);
combo.setStore(store);
combo.setHideTrigger(false);

combo.addSelectionChangedListener(new SelectionChangedListener<BeanModel>() {
@Override
public void selectionChanged(SelectionChangedEvent<BeanModel> se) {
if (se.getSelection().size() > 0) // selection size is always 0 ?
{
UserSig user = (UserSig) (se.getSelection().get(0).getBean());
userEditor.editUser(user);
}
}
});


thanks

rian.k
11 Sep 2009, 4:46 AM
Got it: use setDisplayField() or use a PropertyEditor and overwrite getStringValue() / convertStringValue().