PDA

View Full Version : ListField bindnig does not work



x4444
9 Feb 2010, 11:50 AM
I try to use ListField
reset does not work
if I bind FormBinding to some model and try to use model.set/model.get --they also gives no effect

x4444
9 Feb 2010, 2:02 PM
Gxt 2.1.1 for GWT 2

Also I noticed that getValue() setValue() returns ModelData, but it should be List<ModelData>.
getValue() returns null if more that 1 item selected.

Have to implement my own ListViewAdapted wrapping ListView and extends from FieldAdapter My class has correct getValue/setValue/reset methods and binding works good. Terrible, that standard components still so buggy. :(

x4444
9 Feb 2010, 2:13 PM
Working ListViewAdapter


import java.util.List;

import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ListView;
import com.extjs.gxt.ui.client.widget.form.AdapterField;

public class ListViewAdapter<M extends ModelData> extends AdapterField {

private ListView<M> listView;

public ListViewAdapter() {
this(new ListView<M>());
}

public ListViewAdapter(ListView<M> list) {
super(list);
listView = list;
setResizeWidget(true);
}

public ListView<M> getListView() {
return listView;
}

public void reset() {
super.reset();
listView.getSelectionModel().deselectAll();
}

@Override
public List<M> getValue() {
return listView.getSelectionModel().getSelectedItems();
}

@Override
public void setValue(Object value) {
super.setValue(value);
if (value instanceof List<?>) {
listView.getSelectionModel().deselectAll();
listView.getSelectionModel().select((List) value, false);
}
}
}