DataTable Generics

View: New views
4 Messages — Rating Filter:   Alert me  

DataTable Generics

by Juergen Donnerstag :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Question please. "DataTable"s can have one or more columns. According
to the constructor each IColumn must have the same model object type.
What is the logic behind that? I would assume that each column can
have a different model object type.

        public DataTable(String id, IColumn<T>[] columns, IDataProvider<T>
dataProvider, int rowsPerPage)

Juergen

Re: DataTable Generics

by igor.vaynberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

it is because populateItem is passed in the model that represents the
row of the table, just like listview.

IColumn extends ICellPopulator<T> which has the populateItem that
takes IModel<T>

-igor

On Fri, Jul 31, 2009 at 11:16 AM, Juergen
Donnerstag<juergen.donnerstag@...> wrote:

> Question please. "DataTable"s can have one or more columns. According
> to the constructor each IColumn must have the same model object type.
> What is the logic behind that? I would assume that each column can
> have a different model object type.
>
>        public DataTable(String id, IColumn<T>[] columns, IDataProvider<T>
> dataProvider, int rowsPerPage)
>
> Juergen
>

Re: DataTable Generics

by Juergen Donnerstag :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I understand the technical reason, but I find it strange/wrong to
assume that all columns require the same model object type. Which
means that more often than not you end up with Object as type. And
because the provider requires the same type (Object) ... Does applying
Generics provide any value here?

Juergen

On Fri, Jul 31, 2009 at 8:45 PM, Igor Vaynberg<igor.vaynberg@...> wrote:

> it is because populateItem is passed in the model that represents the
> row of the table, just like listview.
>
> IColumn extends ICellPopulator<T> which has the populateItem that
> takes IModel<T>
>
> -igor
>
> On Fri, Jul 31, 2009 at 11:16 AM, Juergen
> Donnerstag<juergen.donnerstag@...> wrote:
>> Question please. "DataTable"s can have one or more columns. According
>> to the constructor each IColumn must have the same model object type.
>> What is the logic behind that? I would assume that each column can
>> have a different model object type.
>>
>>        public DataTable(String id, IColumn<T>[] columns, IDataProvider<T>
>> dataProvider, int rowsPerPage)
>>
>> Juergen
>>
>

Re: DataTable Generics

by Max Bowsher-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Juergen Donnerstag wrote:
> Question please. "DataTable"s can have one or more columns. According
> to the constructor each IColumn must have the same model object type.
> What is the logic behind that? I would assume that each column can
> have a different model object type.
>
> public DataTable(String id, IColumn<T>[] columns, IDataProvider<T>
> dataProvider, int rowsPerPage)

I'm afraid your assumption is incorrect.

Each IColumn<T> represents a way of rendering a facet of an object of
type T.  The DataTable obtains a collection of objects of type T from
the IDataProvider<T>, and passes them *one* *per* *row* to the
IColumn<T> implementations to populate the cells.

The T in IColumn<T> is the type of the model objects that are being
iterated over row by row, and *not* anything to do with the facet of
that object that is displayed in the column in question.

Max.




signature.asc (204 bytes) Download Attachment