The size() method was one of my biggest stumbling blocks when I started using
DataProvders, but for slightly different reasons (i.e. just having a size
method makes it less maintainable, perform worse, less scalable and gives
less accurate results). But when I tried to work around the size method, I
found it was very deeply embedded in the inner workings of DataTable. I
also think DataTable is too nice of a component to not use. So I came up
with a solution that doesn't require the DataProvider to have a size()
method, but leaves it in DataTable. I've submitted this to JIRA
(https://issues.apache.org/jira/browse/WICKET-579), but since it requires
changing core classes, I wouldn't suggest anybody implement it before it is
an accepted patch. (but maybe some support from others will help it get
accepted).
Kurt
James McLaughlin-3 wrote:
>
> The purpose of size() is to give the DataView an idea of how many
> pages there will be, so this really won't work. You should fetch size
> in a separate query as the number of orders total over all pages, and
> cache that.
>
> best,
> jim
>
> On 5/29/07, V. Jenks <[EMAIL PROTECTED]> wrote:
>>
>> I'm trying to use a provider class for a DataView so I can do
>> paging/sorting,
>> etc. It looks like this:
>>
>> ************************************************
>> public class OrderProvider implements IDataProvider
>> {
>> private transient List<Order> orders;
>>
>> public OrderProvider()
>> {
>> }
>>
>> public Iterator iterator(int first, int count)
>> {
>> this.orders =
>> WicketHelper.<List<Order>>getDetachedModelObject(
>> OrderProxy.getAll(first, first + count));
>>
>> return this.orders.iterator();
>> }
>>
>> public IModel model(Object model)
>> {
>> return WicketHelper.getDetachedModel(model);
>> }
>>
>> public int size()
>> {
>> return this.orders.size();
>> }
>> }
>> ************************************************
>>
>> I thought this would work but it looks like size() is called first, since
>> I
>> get a NPE:
>>
>> ************************************************
>> Caused by: java.lang.NullPointerException
>> at com.myapp.provider.OrderProvider.size(OrderProvider.java:36)
>> ************************************************
>>
>> It works if size() makes a call to the database to get a count of
>> records...but I'm trying to use a global field to prevent that data call.
>>
>> Any suggestions?
>> --
>> View this message in context:
>> http://www.nabble.com/Chicken-and-egg-w--Data-Provider-tf3834369.html#a10855464
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Wicket-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/wicket-user
>>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
--
View this message in context:
http://www.nabble.com/Chicken-and-egg-w--Data-Provider-tf3834369.html#a10875427
Sent from the Wicket - User mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user