Not a good idea for large objects. A few days back I improved load time of a page from more then 40 sec to about 5 sec by replacing "new Model(object)" with a proper LoadableDetachableModel.

Nevertheless, there is no reason to let the LoadableDetachableModel get the object if you already have it, just pass the object to the constructor!

E.g. see first ctor below.

public class LoadableMemberModel
       extends LoadableDetachableModel<Member> {

   @SpringBean
   private MemberService memberService;

   private long memberId;

   //
   // Constructor that has object has direct parameter
   //
   public LoadableMemberModel(Member member) {
       super(member);
       this.memberId = member.getId();
   }
*
*    public LoadableMemberModel(long memberId) {
       this.memberId = memberId;
   }

   protected Member load() {
       InjectorHolder.getInjector().inject(this);
       return memberService.getById(memberId);
   }
}



Regards,
   Erik.


Graeme Knight wrote:
Hey Jeremy,

Thanks for the heads up - actually that's what I ended up doing this
morning. Works like a charm!

Cheers, Graeme.


Jeremy Thomerson-5 wrote:
In my apps, I bring them all in whenever the first call to iterator or
size
is done, and cache them until detach. It's a very reasonable pattern. Then
in the model method, I basically do new Model(object)....


--
Jeremy Thomerson
http://www.wickettraining.com


On Tue, Nov 11, 2008 at 8:03 AM, Graeme Knight <[EMAIL PROTECTED]>
wrote:

Hi.

From the examples I've seen the IDataProvider implementation of the
iterator
method brings back (for example) a list of keys from the database.

The model method uses something like a LoadableDetachableModel to
populate
a
model for use by the consumer using the list of keys previously
retrieved.

This seems like a lot of database hits to me. Is this simply because of
the
serialization/model mechanism?

It seems to me that the iterator could/should bring back the data in one
hit
and then after use be detached. Is this common?

Many thanks, Graeme.
--
View this message in context:
http://www.nabble.com/IDataProvider-Implementation.-tp20440141p20440141.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]





--
Erik van Oosten
http://www.day-to-day-stuff.blogspot.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to