ambro23
9 Mar 2009, 6:15 PM
Hi,
I'm using Hibarnate and Gilead on server side. My domain model objects implement BeanModelTag, so I can create nice grids using GXT.
However, I have the impression, is that the grid API of GXT is not 100% Java friendly and it relies too much on ModelData. I'd like to see a type-safe API.
Is it something that's going to change in the future maybe?
My suggestions:
(In the examples, I have products and categories. Each product has a category and each category has a name attribute.)
1. Column rendering now (column config for category name in a product list grid)
ColumnConfig categoryNameCol = new ColumnConfig("category", "Category", 100);
makeCol.setRenderer(new GridCellRenderer()
{
@Override
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore store)
{
ModelData make = model.get("category");
return make.get("name");
}
});
Suggestion:
makeCol.setRenderer(new GridCellRenderer<Product>()
{
@Override
public String render(Product product, String property, ColumnData config, int rowIndex, int colIndex, ListStore store)
{
return product.getCategory().getName();
}
});
2. Column config: now: same as above
ColumnConfig productNameCol= new ColumnConfig("name", "Product name", 100);
Column config in a type safe mode
ColumnConfig<Product> productNameCol = new ColumnConfig<Product>(Category", 100)
{
public String render(Product product, String property, ColumnData config, int rowIndex, int colIndex, ListStore store)
{
return product.getName();
}
};
3. Grid declaration
ListStore<BeanModel> store = new ListStore<BeanModel>(loader);
ColumnModel cm = ...
grid = new Grid<BeanModel>(store, cm);
Type-safe version would look like this:
ListStore<Product> store = new ListStore<Product>(loader);
ColumnModel<Product> cm = ...
grid = new Grid<Product>(store, cm);
Please let me know what do you think.
-Milan
I'm using Hibarnate and Gilead on server side. My domain model objects implement BeanModelTag, so I can create nice grids using GXT.
However, I have the impression, is that the grid API of GXT is not 100% Java friendly and it relies too much on ModelData. I'd like to see a type-safe API.
Is it something that's going to change in the future maybe?
My suggestions:
(In the examples, I have products and categories. Each product has a category and each category has a name attribute.)
1. Column rendering now (column config for category name in a product list grid)
ColumnConfig categoryNameCol = new ColumnConfig("category", "Category", 100);
makeCol.setRenderer(new GridCellRenderer()
{
@Override
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore store)
{
ModelData make = model.get("category");
return make.get("name");
}
});
Suggestion:
makeCol.setRenderer(new GridCellRenderer<Product>()
{
@Override
public String render(Product product, String property, ColumnData config, int rowIndex, int colIndex, ListStore store)
{
return product.getCategory().getName();
}
});
2. Column config: now: same as above
ColumnConfig productNameCol= new ColumnConfig("name", "Product name", 100);
Column config in a type safe mode
ColumnConfig<Product> productNameCol = new ColumnConfig<Product>(Category", 100)
{
public String render(Product product, String property, ColumnData config, int rowIndex, int colIndex, ListStore store)
{
return product.getName();
}
};
3. Grid declaration
ListStore<BeanModel> store = new ListStore<BeanModel>(loader);
ColumnModel cm = ...
grid = new Grid<BeanModel>(store, cm);
Type-safe version would look like this:
ListStore<Product> store = new ListStore<Product>(loader);
ColumnModel<Product> cm = ...
grid = new Grid<Product>(store, cm);
Please let me know what do you think.
-Milan