when you save the entity, make sure you update the ID in the LDM to
point to the newly created object.

Martijn

On Thu, Jan 22, 2009 at 5:05 PM, pieter claassen <[email protected]> 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);
>    }
>
> }
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to