Reputation: 542
I am trying to get a GXT 3 Grid running, but getting the following exception when running GWT compile form Eclipse:
java.lang.NullPointerException
at com.sencha.gxt.data.rebind.ModelKeyProviderCreator.getObjectType(ModelKeyProviderCreator.java:40)
Code to launch the grid and make it visible:
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);
the grid data 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;
}
}
The supporting DataProperties class:
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();
}
Upvotes: 2
Views: 718
Reputation: 18331
From your code:
public interface DataProperties extends PropertyAccess {
@Path("name")
ModelKeyProvider key();
ValueProvider<MyGridData, String> name();
ValueProvider<MyGridData, String> value();
}
You've got an error here - without generics, the compiler can't figure out what you need. Your IDE should be warning you about your raw use of both ProperyAccess and ModelKeyProvider. Both of those need to refer to MyGridData. Try this instead:
public interface DataProperties extends PropertyAccess<MyGridData> {//here
@Path("name")
ModelKeyProvider<MyGridData> key();// and here
ValueProvider<MyGridData, String> name();
ValueProvider<MyGridData, String> value();
}
Upvotes: 2