Why would want to cache the result? what happened if the results returned are
big and if that s not enought, what will happened if 5000 concurrent users
are accessing the paging and hence caching a potential big records returned?
the memory of the server will be eaten away right? 


Timo Stamm wrote:
> 
> Steve Knight schrieb:
>> If my SortableDataProvider implementation will always return the max
>> number
>> of results (I'm not using paging), is it safe to have the size() method
>> simply return Integer.MAX_VALUE instead of performing a database query to
>> count the actual results?
> 
> You shouldn't. It might not give you problems right now, but you break 
> the contract with the interface.
> 
> You can cache the result so that you do only one query per request to 
> get both the result size and the result values. Use onDetach to clear 
> the cache after each request.
> 
> 
> It should look like this (pseudo-code):
> 
> 
> private List result;
> 
> void onDetach() {
>    result = null;
> }
> 
> Iterator iterator(from, to) {
>     return getData().iterator();
> }
> 
> int size() {
>    return result.size();
> }
> 
> private Collection getData() {
>    if (result == null) {
>      result = dbquery(from, to);
>    }
>    return result;
> }
> 
> 
> Timo
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> 
> 

-- 
View this message in context: 
http://www.nabble.com/IDataProvider.size%28%29-tf1317737.html#a11055063
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to