I am using PropertyModel and Compoundpropertymodel in my wicket application. I use them as local variables and not as members of the page classes. Do i have to override the onDetach() Function to detach the models when they are local? Or are only member variables serialized into the session?
Example:
TextField<String> title = new TextField<String>("title", new PropertyModel<String>(position, "title"));
title.setRequired(true);
form.add(positionTitle);
In this instance, and in most uses of such models in Wicket, the initial assignment is to a local variable, but the object is put into something that is not local.
Your
formis almost certainly a field or contained in something that is, and is serialized into the session. It contains thetitlefield, which in turn contains the model.So it will be serialized, and yes you should probably implement
onDetach().Edit:
As noted in a comment, what really matters is whether it is part of the component hierarchy of a page, rather than whether it is a field. It does on some level amount to the same thing, as the child components of a page or any other component are held in a field
childrenin the superclassorg.apache.wicket.MarkupContainer.