[Databinding] ComboViewer default selection [message #558686] |
Tue, 14 September 2010 01:30 |
Hugo Herrera Messages: 20 Registered: July 2009 |
Junior Member |
|
|
Hola,
need help with databinding.
I have an application with a ComboViewer listing country states. When a new Person is created, ComboViewer is working as expected and State is properly saved in Person. The problem is when opening for editing, the ComboViewer is not listing the saved State as the defaulted selected item. It is displaying blanks. I tried using ComboViewer.setSelection() but same results. Any Idea? am i doing the binding correctly?
TextFields are working fine with binding.
Here is the code.
class Person {
String name;
State state;
...
}
class State {
Integer id;
String name;
...
}
Person customer;
List<State> states = sql-list-of-states;
Label stateLabel = new Label(composite2, SWT.NONE);
stateLabel.setText("State:");
Combo stateCombo = new Combo(composite2, SWT.READ_ONLY);
ComboViewer stateComboViewer = new ComboViewer(stateCombo);
stateComboViewer.setContentProvider(new ArrayContentProvider());
stateComboViewer.setInput(states);
doBindValue(stateComboViewer, "state");
....
private void doBindValue(ComboViewer comboViewer, String propertyName) {
IObservableValue model = BeansObservables.observeValue(customer,
propertyName);
dbc.bindValue(ViewersObservables. observeSingleSelection(comboViewer), model);
model.addChangeListener(dirtyChangeListener);
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03405 seconds