public class Data {
private String name;
private String value;
public Data(String name, String value) {
super();
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public String getValue() {
return value;
}
public void setName(String name) {
this.name = name;
}
public void setValue(String value) {
this.value = value;
}
}
To do it I need of:
1)a model(Data);
2)an interface(DataProperties) that extends PropertyAccess,
3)a ListStore (a container populated with the model,the ColumnConfig,the ColumnModel).
It establishes the relationship between the table and the model.
I would want to create that four elements(DataProperties,ListStore,ColumnConfig,ColumnModel) in a generic way so I can reuse them in another model.Is there a way to do it?
You do not need to use PropertyAccess to create grids, or anything in GXT. PropertyAccess is just a way to look at bean-like models, and provide access to ValueProviders, ModelKeyProviders, and LabelProviders within those beans. Often, if you have a dynamic data model, you can make your own such provider implementations that can generically read from your data model.
Check out the ValueProvider section of this blog post http://www.sencha.com/blog/building-gxt-charts/ for a discussion on how to make a very dynamic data model and how to make ValueProviders that can read them. The example is made for Charts, but the same principle applies for Grids as well.
private UserProperties userProperties = GWT.create(UserProperties.class);
List<ColumnConfig<User, ?>> ccs = new LinkedList<ColumnConfig<User, ?>>();
//my problem is here... ccs.add(new ColumnConfig<User, String>(userProperties.password(), 200, "")); ccs.add(new ColumnConfig<User, String>(userProperties.userId(), 200, "")); ....
I'd want to create something as this:
List<ColumnConfig<GenericObj, ?>> ccs = new LinkedList<ColumnConfig<GenericObj, ?>>();
//for all fields of GenericObj
ccs.add(new ColumnConfig<GenericObj, String>(*something that substitute the bold line*, 200, ""));