Hi Michael,

there's no requirement for components inside ListView to be stateless - I wonder were you got that from. You can have Links, Buttons or anything else in there so removing all on detach is a recipe for disaster for the next incoming request.

Sven

Michael Gottschalk wrote:
Hi,

I have a question concerning the serialization of subcomponents of ListView.

If I understand correctly, then the components that are added to a ListView in the populateItem method should be stateless, since they are removed in the onPopulate method each time the list view is rendered (as long as reuseItems is set to false).

Nevertheless, the subcomponents are saved in the ListView and so they are serialized/stored in the session after the page with the ListView has been rendered. This seems unnecessary to me. Why do we have to store components that are discarded before the next rendering phase anyway?

So I created a subclass of ListView with the following method overridden:

@Override
protected void onDetach() {
    super.onDetach();

    if ( !getReuseItems() ) {
        removeAll();
    }
}

This removes the subcomponents before the page is stored in the session and should save some memory in most cases.

Is there a reason why this is not done in ListView itself? Has nobody thought about it yet or could there be any problems with this approach?

Cheers,
Michael

---------------------------------------------------------------------
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

Reply via email to