http://wicketinaction.com/2008/09/building-a-smart-entitymodel/

notice the deatch() implementation

-igor

On Thu, Jan 22, 2009 at 8:05 AM, pieter claassen <pie...@claassen.co.uk> wrote:
> I am using wicket 1.3.5 and db4o 7.4.63.11890.
>
> My objects are being passed between pages using a subclass of
> LoadableDetachableModel (see below)
>
> My problem is:
> 1. I edit an object on PageA
> 2. I use the back button and then re-submit the form I edited and now I have
> two objects in the database.
>
> Any ideas on why this is happening?
>
> Cheers,
> Pieter
>
>
> package com.musmato.wicket.model;
>
> import org.apache.wicket.model.LoadableDetachableModel;
>
> import com.musmato.dao.BaseFactory;
>
> public abstract class BaseWebModel<T> extends LoadableDetachableModel {
>
>    private static final long serialVersionUID = 1L;
>
>    protected Long id;
>
>    public abstract Class<T> getBaseClass();
>
>    public abstract BaseFactory<T> getFactory();
>
>    public BaseWebModel(Long id) {
>        this.id = id;
>    }
>
>    public BaseWebModel(T object) {
>        this.id = getFactory().getID(object);
>    }
>
>    @Override
>    protected Object load() {
>
>        if (id == null) {
>            return getFactory().getNewObject();
>        }
>
>        return getFactory().getById(id);
>    }
>
> }
>

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

Reply via email to