我正在尝试运行 GXT 3 Grid,但在运行 GWT 编译表单 Eclipse 时出现以下异常:
java.lang.NullPointerException
at com.sencha.gxt.data.rebind.ModelKeyProviderCreator.getObjectType(ModelKeyProviderCreator.java:40)
启动网格并使其可见的代码:
DataProperties dp = GWT.create(DataProperties.class);
List<ColumnConfig<MyGridData, ?>> css = new LinkedList<ColumnConfig<MyGridData, ?>>();
css.add(new ColumnConfig<MyGridData, String>(dp.name(), 200, "Name"));
css.add(new ColumnConfig<MyGridData, String>(dp.value(), 200, "Value"));
ColumnModel<MyGridData> cm = new ColumnModel<MyGridData>(css);
ListStore<MyGridData> s = new ListStore<MyGridData>(dp.key());
s.add(new MyGridData("name1","value1"));
s.add(new MyGridData("name2","value2"));
s.add(new MyGridData("name3","value3"));
s.add(new MyGridData("name4","value4"));
Grid<MyGridData> g = new Grid<MyGridData>(s, cm);
addToDisplay(g);
网格数据 bean:
public class MyGridData{
private String name;
private String value;
public MyGridData(String name, String value) {
super();
this.name = name;
this.value = value;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setValue(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
}
支持的 DataProperties 类:
import com.google.gwt.editor.client.Editor.Path;
import com.sencha.gxt.core.client.ValueProvider;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
public interface DataProperties extends PropertyAccess {
@Path("name")
ModelKeyProvider key();
ValueProvider<MyGridData, String> name();
ValueProvider<MyGridData, String> value();
}