I'd love to see this (along w/ an example or two on usage) ;)

On 3/15/06, Frank Silbermann <[EMAIL PROTECTED] > wrote:

The DataTable in Wicket Extensions 1.1 handles paging and sorting, but you must build a custom IDataProvider that accumulates the sorting instructions from the DataTable and provides sorted subsets of the data when requested by the DataTable (which handles the actual paging display).

 

DataTable and supporting classes have been greatly refactored in Wicket Extensions 1.2 to give the user much more flexibility in the set of features desired.  The API changes will break Wicket 1.1 programs, so if you need to subclass anything to modify its behavior, I would suggest going to Wicket 1.2 now.  Otherwise, you can upgrade fairly easily at any time by replacing Wicket 1.1 DataTable with Wicket 1.2 DefaultDataTable.  Wicket 1.2 DataTable is more flexible but less complete; DefaultDataTable subclasses it to provide defaults which make it behave like the Wicket 1.1 DataTable.

 

I have come up with my own subclass of DataTable and implementation of IDataProvider to display any arbitrary database java.sql.ResultSet.  The basic idea is that my IDataProvider implementation contains a List of rows, each row consisting of a List of Object.  Also in the implementation is an array of descriptors, one per column, each of which contains the column name and an indicator as to whether I want to be able to sort on that column.  (The column name comes from the ResultSetMetadata; a method is provided to set the sortability flag.)  My implementation of the abstract method to deliver a sequence of rows will delegate to the List.sublist() command from the Java Collections API, and each time the DataTable delivers a sort criteria I apply the Collections.sort() method to my list of rows, passing it a Comparator that delegates to the Comparator of the Object at the relevant column index.  My implementation of IDataProvider can also look at my array of column descriptors and generate a list of IColumn objects (needed to construct the DataTable).

 

It's actually a bit more complicated than that (and a work in progress), because I have complicated the above mechanisms to deal with the possibility of a summary row at the end, and when rows are requested, the query string will be recalculated based on form data -- and if it has changed since the last request then the data will be refreshed from the database and the current page set back to 1.

 

The code is actually quite compact; when I'm finished I'll post it to the list if there is any interest.

 

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Igor Vaynberg
Sent:
Tuesday, March 14, 2006 5:21 PM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] DataView (extentions)

 

there is also a DataTable component which wraps DataView+paging+sorting.

-Igor

On 3/14/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:

I'm using 1.1.1  Are there any plans to whittle down the amount of code it takes to implement paging & sorting?  Has it changed at all in 1.2?  I spent a lot of time w/ ASP.NET (which wicket feels quite similar to) and there's a DataGrid component that has properties to set paging & sorting w/o any extra work.  Something like that would be really convenient.

 

On 3/14/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:

are you using 1.1 ? or 1.2 ?
there used to be a constructor that took model in 1.1 i think. the model object must be of type IDataProvider.



-Igor

On 3/14/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:

Sorry, I didn't mention that the List is wrapped in a detached model....so it's an IModel, not List in the constructor.

 

On 3/14/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:

yes DataView works with IDataProvider instead of list. not sure why you didnt get a compile error since there is no (String,List) constructor.


there are examples of dataview and datatable under wicket-examples/repeaters

-Igor

 

On 3/14/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:

So, I'm trying to use a DataView so I can page a collection of objects
from a session bean.

I create the List collection (loadingModel) and pass it into the DataView:

DataView productsDataView = new DataView("productsDataView", loadingModel)

...but I'm getting an exception at runtime:

"Caused by: java.lang.ClassCastException: java.util.ArrayList"

I assume then, it's not like the ListView in that it will not take a
List directly?  Or, have I done something wrong?

Thanks!

 

 

 



 


Reply via email to