Hi,
>At the current implementation they need to do
>cols.add(new LocationColum<Location>(...));
>instead of just
>cols.add(new LocationColum(...));
I think you mean LocationColumn<Person>.
>nice feature of PropertyColums: Not to have a too strength coupling of
what the column displays in the cell and what the data table shows.
As I see it, columns decide what to display (e.g. a person's location)
and the component provided in #popuplateItem() decides how to display
this information.
Let us know when you figured out how to improve separation of these
concerns.
Have fun
Sven
Am 09.03.2015 um 10:29 schrieb Patrick Davids:
Hi Sven,
I did already implement it this way... and its working.
But my team members asked (more the client developers point of view),
why the column-class itself is not a generic of Location, like this.
public class LocationColumn extends PropertyColumn<Location> {
...
}
At the current implementation they need to do
cols.add(new LocationColum<Location>(...));
instead of just
cols.add(new LocationColum(...));
Thats why I "forwarded" the question here, because I studied a bit the
Column-Hierarchie code and also wondered about this strength coupling
between T of ICellPopulator and T of rowModel and T of DataTable.
I suppose my team members see the PropertyColumn more like the usage
of a PropertModel.
The generic of a PropertyModel is the type, which is returned by the
expression.
The generic of a PropertyColumn is the DataTables generic / rowModel
generic, not what its expression retrieves/returns/displays.
I think thats it...
As more as I think about this issue, maybe this could be a nice
feature of PropertyColums.
Not to have a too strength coupling of what the column displays in the
cell and what the data table shows.
kind regards
Patrick
Am 05.03.2015 um 18:43 schrieb Sven Meier:
Hi Patrick,
you can let your column implementation be generic:
public class LocationColumn<T> extends PropertyColumn<T> {
public LocationColumn(String expressionToLocation){
super(Model.of("Location"), expressionToLocation);
}
@Override
public void populateItem(Item<ICellPopulator<T>> cellItem,
String componentId, IModel<T> rowModel) {
cellItem.add(new Label(componentId, new
LocationFormatModel((IModel<Location>)createDataModel(rowModel),
Model.of(Session.get().getLocale()))));
}
}
What do you need more?
Regards
Sven
Am 05.03.2015 um 15:34 schrieb Patrick Davids:
Hi Sven,
thanx for feedback.
Ok, how to implement the LocationColumn more reusable?
I dont want to be bound to a Datatable of Persons.
I'd like to have a Column which works with a Locations, independently
from which model-object the expression fetches the Location.
Is there any way to do that?
best regards
Patrick
Am 05.03.2015 um 15:19 schrieb Sven Meier:
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
---------------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org