Finally I got it - I use such DataProvider:
private class SearchDataProvider implements IDataProvider {
private String query;
private int resultsPerPage;
private SearchDAO.SearchResults searchedAdverts;
private Integer resultsCount;
public SearchDataProvider(String query, int resultsPerPage) {
this.query = query;
this.resultsPerPage = resultsPerPage;
}
public Iterator iterator(int first, int count) {
if(searchedAdverts == null) {
searchedAdverts =
searchDAO.getSearchedAdverts(this.query, first, count);
}
return searchedAdverts.getResults().iterator();
}
public IModel model(Object object) {
return new Model((Advertisement) object);
}
public int size() {
if(resultsCount == null) {
searchedAdverts =
searchDAO.getSearchedAdverts(this.query, 0,
this.resultsPerPage);
resultsCount = searchedAdverts.getCount();
}
return resultsCount;
}
public void detach() {
searchedAdverts = null;
}
}
Transient doesn't work in my case, but setting null on object in
detach() makes what transient should. Size is asked only once for a
search, and number of results is set as Integer (also could be added
to iterator if some results appear in time of walking thru the search
results), iterators() if size is known also would be queried once -
this is what should be done.
Best regards,
Adr
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]