wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bas Gooren <...@iswd.nl>
Subject Re: DataTable and unserializable data
Date Fri, 21 Jun 2013 14:38:35 GMT
Hi,

In your example, the loadableDetachableModel (LDM) doesn't help.
It references the final object passed in to the model() method, which 
means the contact object is serialized.

The point of using LDMs is that they only store a reference (e.g. an ID) 
of an object, and can re-create or lookup the actual object based on 
that reference.

E.g.:

ContactModel extends LDM<Contact> {
  private long contactId;

  ContactModel(Contact contact) {
   setObject(contact);
  }

  setObject(Contact contact) {
   super.setObject(contact);

   this.contactId = contact != null ? contact.getId() : null;
  }

  load() {
   return this.contactId != null ? new ContactDao().find(contactId) : null;
  }
}

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 21-6-2013 12:16, schreef Baptiste75:
> Is it possible to use an implementation of DataTable (like
> AjaxFallbackDefaultDataTable) with unserializable data?
> My page throws the usual NotSerializableException, in spite of using
> LoadableDetachableModel everywhere I can.
> I am tearing my hair out to understand where the problem comes from. Can
> someone please help?
> Thanks.
>
> I want to precise that I use a LoadableDetachableModel in the method model()
> of my DataProvider:
> @Override
> public IModel<Application> model(final Contact object) {
> 	return new LoadableDetachableModel<Contact>() {
> 		@Override
> 		protected Contact load() {
> 			return object;
> 		}
> 	};
> }
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataTable-and-unserializable-data-tp4659659.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message