Am 21.08.13 01:01, schrieb Michael Chandler:
.. will expose me to a serialization error unless I put it in a Wicket model.  
Am I correct about this?

There is nothing special about the serialization in Wicket. Wicket uses the default Java serialization. So every field not marked as transient will be serialized. As Martin said: watch out for non static inner classes or anon classes because you can not see the field which is created for any reference to something from the outer scope.

To put your stuff behind a model has a benefit: if wicket is "done" with your page (response is written to the client) it will throw away anything changeable from your models. In your case the list of the entries from your database is flushed from memory.

I would not recommend to put long living data into your components (which then must be serialize-able). You should put something like this into a cache.

You can put everything needed to load you date from somewhere into an model.

public class Customers extends LoadableDetachableModel<List<Customer>> {
  @SpringBean
  CustomersDao dao;

  public Customers() {
    Injector.get().inject(this);
  }

  public List<Customer> load() {
    return dao.allCustomers();
  }
}

This way your component must not deal with anything else .. it will use model which provides the data:)

Michael:)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to