You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Baptiste75 <po...@live.fr> on 2013/06/21 12:16:24 UTC
DataTable and unserializable data
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
Re: DataTable and unserializable data
Posted by Bas Gooren <ba...@iswd.nl>.
Hi,
Most wicket components use models and providers mainly so you can decide
if the data should be serialized or not. You can control what kind of
models are used, and how much data they serialize.
If you use proper loadable & detachable models, then wicket will not
serialize your Contact instances.
What happens is this: wicket renders your datatable, and if it (or
something else on the page) contains stateful components, serializes the
page.
Now two things can happen (amongst others, and not mutually exclusive):
A - a stateful component is invoked, e.g. the user clicks a link inside
your datatable. Wicket now looks up the specific link inside your
datatable (as it was last rendered), and load()s your model, and thus
the Contact it points to.
B - the page is re-rendered. Wicket basically removes all rows inside
your datatable, and re-renders its based on your provider.
A datatable is basically a fancy RefreshingView with some additional
components, and as the name of that class points out: the contents are
refreshed on each render.
I haven't taken an in-depth look myself yet, but I'm sure this is
explained in the excellent free wicket guide recently created by another
wicket user: http://wicket.apache.org/learn/books/freeguide.html
Met vriendelijke groet,
Kind regards,
Bas Gooren
Op 21-6-2013 18:48, schreef Baptiste75:
> A thousand thanks, Sebastian!
> Your sample did it!
>
> Juste a last question, out of curiosity (if you have a clue):
> Did this exception occur because DataTable, after retrieving the user
> objects from the provider, *stores* them somewhere in an inner component?
> And so when the Page is serialized, the DataTable is too, and my objects
> Contact as well?
> Because then I am wondering the point for a DataTable to memorize the user
> data... I would expect it to iterate on them, display, and then get rid of
> them, transiently...
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataTable-and-unserializable-data-tp4659659p4659678.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
>
Re: DataTable and unserializable data
Posted by Baptiste75 <po...@live.fr>.
A thousand thanks, Sebastian!
Your sample did it!
Juste a last question, out of curiosity (if you have a clue):
Did this exception occur because DataTable, after retrieving the user
objects from the provider, *stores* them somewhere in an inner component?
And so when the Page is serialized, the DataTable is too, and my objects
Contact as well?
Because then I am wondering the point for a DataTable to memorize the user
data... I would expect it to iterate on them, display, and then get rid of
them, transiently...
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataTable-and-unserializable-data-tp4659659p4659678.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
Re: DataTable and unserializable data
Posted by Bas Gooren <ba...@iswd.nl>.
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
>
Re: DataTable and unserializable data
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
When NotSerializableException is thrown its message pinpoints the
problematic field.
Show us the exception message.
On Fri, Jun 21, 2013 at 12:16 PM, Baptiste75 <po...@live.fr> wrote:
> 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
>
>