Hi,
generic T is identical for the DataTable, and it's IColumns: it's the
type of the row models.
A column is responsible to provide a cell component for a row: For
DataTable only the input (e.g. Person) is interesting, the output
(Location) doesn't matter.
Your LocationColumn should extend PropertyColumn<Person>:
public class LocationColumn extends PropertyColumn<Person>{
public LocationColumn(String expressionToLocation){
super(Model.of("Location"), expressionToLocation);
}
@Override
public void populateItem(Item<ICellPopulator<Person>> cellItem,
String componentId, IModel<Person> rowModel) {
cellItem.add(new Label(componentId, new
LocationFormatModel((IModel<Location>)createDataModel(rowModel),
Model.of(Session.get().getLocale()))));
}
}
Have fun
Sven
Am 05.03.2015 um 12:26 schrieb Patrick Davids:
Hi all,
whats the meaning of generic T on DataTables vs T of IColumn and T of
ICellPopulator?
As I understand its the type of object shown by the table rows.
Reading the javadoc of AbstractColumn it says T (if I understand
correct), its the type of object shown by the cell itself.
But DataTable and its internal list of columns are bound together.
T of both must be the same...
I tried to implement something like this, and here I get problems.
List<IColumn<Person, Void>> cols = new ArrayList<>();
cols.add(new PropertyColumn<Person, Void>(Model.of("Name"), "name"));
(compiler error)
cols.add(new LocationColumn("location"));
(compiler error)
new DataTable<Person, Void>("id", cols, new
ListDataProvider<Person>(), 50);
public class LocationColumn extends PropertyColumn<Location>{
public LocationColumn(String expressionToLocation){
super(Model.of("Location"), expressionToLocation);
}
@Override
public void populateItem(Item<ICellPopulator<Location>> cellItem,
String componentId, IModel<Location> rowModel) {
cellItem.add(new Label(componentId, new
LocationFormatModel(rowModel, Model.of(Session.get().getLocale()))));
}
}
Also the Generic of ICellPopulator is bound to T of column.
I always thought it could be possible to implement sub-class columns
to allow special renderings of table-cells.
But how can I achieve this, if also ICellPopulator is bound to T of
the rowModel?
kind regards
Patrick
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org