Hello everybody!
There is a page PagingPage in Wicket Examples(repeater folder)
And this page contain next code:
DataView dataView = new DataView("pageable", new ContactDataProvider())
ContactDataProvider implements method iterator:
public Iterator iterator(int first, int count)
{
return getContactsDB().find(first, count, "firstName",
true).iterator();
}
It returns List of Contacts.
And there is next code:
/**
* wraps retrieved contact pojo with a wicket model
*
* @see
org.apache.wicket.markup.repeater.data.IDataProvider#model(java.lang.Object)
*/
public IModel model(Object object)
{
return new DetachableContactModel((Contact)object);
}
So why we need to wrap every item of this List to DetachableContactModel.
When page open in a first time there will be only on SELECT request to
Database(iterator(int first, int count) -> SELECT * FROM Contacts LIMIT
first, count)). But when page will open in a second time there will be N
SELECTs (where N == count) for every Contact object in
DetachableContactModel because it calls method load().
So I don't understand why wrap items(Contact in this example) to
DetachableContactModel? One select to retrieve all Contact on the page
better than N SELECTs, isn't it?
P.S. Sorry for my bad english
--
View this message in context:
http://www.nabble.com/Confused-with-IDataProvider-tp15039652p15039652.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]