I prefer not to do it that way because it requires a potentially large list
of records to be pulled up initially whereas now, I'm only pulling the
records on the current page, making it much faster. I pass the x & y right
through to the data access layer.
Johan Compagner wrote:
>
> this only works if you have a seperate method:
>
> private List getOrders()
> {
> if (orders == null)
> {
> orders = DAO.getOrders()
> }
> }
>
> iterator()
> {
> return getOrders().sublist(x,y).iterator()
> }
>
>
> size()
> {
> return getOrders().size();
> }
>
> detach()
> {
> orders = null;
> }
>
> johan
>
> 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#a10879506
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