super(l) stores the model as an instance variable on the superclass. When getObject() is called on the LDM, it checks to see if the instance variable (the model object) is null. If it is null, load() will be called to populate the model. Once the request is complete the model is detached (instance variable set to null). Then the cycle repeats...
A use case for super(l) is SortableDataProvider (SDP) seen below and taken from Wicket repeaters example. The SDP retrieves the records of interest for pagination using iterator(), then creates a model. If the object was not passed into the DetachableContactModel, the load() method would make another db call to populate the model. public class SortableContactDataProvider extends SortableDataProvider<Contact> { public SortableContactDataProvider() { // set default sort setSort("firstName", SortOrder.ASCENDING); } public Iterator<Contact> iterator(int first, int count) { return service.find(first, count, getSort()).iterator(); } public int size() { return service.getCount(); } public IModel<Contact> model(Contact object) { return new DetachableContactModel(object); } } From: James Carman <ja...@carmanconsulting.com> To: users@wicket.apache.org Date: 03/01/2011 01:11 PM Subject: Re: Perfomance of IDataProvider Sent by: jcar...@carmanconsulting.com It is referenced by the superclass (LoadableDetachableModel in this case). It will "cache" the list until after the request cycle is complete. Upon subsequent request cycles, the load() method will be called to re-load the list. On Tue, Mar 1, 2011 at 12:51 PM, Juansoft <andresnet2...@yahoo.es> wrote: > Thank for the replies! > > > MZemeck wrote: >> >> Here's a start, please anyone correct me if I've made any mistakes... >> >> public class ListLDM extends LoadableDetachableModel<List> { >> >> private String id; >> >> public ListLDM(List l, String id) { >> //constructor with primed model >> super(l); >> this.id = id; >> } >> >> public ListLDM(String id) { >> //constructor with empty model >> this.id = id; >> } >> >> @Override >> protected List load() { >> return service.getList(id); >> } >> >> } >> >> >> > > In this example , the object that you're wrap in the inner model ("List l" > that you are send in super() constructor) is not used anywhere... ¿i'm > wrong? in this case , ¿why should be using this (in reference a List l in > constructor)? > > > > > ----- > Another "wicket" newbie programmer > ******************************** > Wicket en Español - > > http://aprendiendowicket.wordpress.com > -- > View this message in context: http://apache-wicket.1842946.n4.nabble.com/Perfomance-of-IDataProvider-tp3325777p3330259.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org Notice: This communication, including any attachments, is intended solely for the use of the individual or entity to which it is addressed. This communication may contain information that is protected from disclosure under State and/or Federal law. Please notify the sender immediately if you have received this communication in error and delete this email from your system. If you are not the intended recipient, you are requested not to disclose, copy, distribute or take any action in reliance on the contents of this information.