Igor, thanks for your comments so far. After a lot of struggle, I now have the following strategy in place which just provides me with the old results, duplicate data in the database when I add a template, and then press the back button and add it again.
Here is an example of how I create a new object in wicket (when I need a transient model). I am trying to understand how wicket gets/sets the objects. Any pointers? public class TemplateAddPage extends AuthPage { public TemplateAddPage() { setModel(new CompoundPropertyModel(new Template())); add(new TemplateAddForm("templateaddform")); } @Override public Role[] getAllowedRoles() { return new Role[] { Role.ADMIN, Role.THERAPIST }; } private class TemplateAddForm extends Form { public TemplateAddForm(String id) { super(id); add(new RequiredTextField("name")); add(new RequiredTextField("version")); add(new RequiredTextField("author")); add(new TextArea("description")); add(new TemplateDropDownChoicePanel("ddcpanel")); } @Override public void onSubmit() { Template template = (Template) getInnermostModel().getObject(); WicketApplication.get().getTemplateFactory().store(template); setResponsePage(new TemplateListPage()); } } } And here is my base IModel class public abstract class BaseWebModel<T> implements IModel { private static final long serialVersionUID = 1L; protected Long id = null; protected T object = null; public abstract Class<T> getBaseClass(); public abstract BaseFactory<T> getFactory(); public BaseWebModel(T object) { this.id = getFactory().getID(object); this.object = object; } public T getObject() { if (object == null) { object = getFactory().getById(id); if (object == null) { throw new RuntimeException("Object not found"); } } return object; } public void setObject(Object object) { getFactory().store((T) object); } public void detach() { if (object != null) { if (id != null) { id = getFactory().getID(object); object = null; } } } On Thu, Jan 22, 2009 at 7:58 PM, Igor Vaynberg <igor.vaynb...@gmail.com>wrote: > when you click the back button you go to a previous version of the > page (a snapshot as it existed when rendered). in that version the id > inside the model is still null. > > -igor > > On Thu, Jan 22, 2009 at 10:48 AM, pieter claassen > <pieter.claas...@gmail.com> wrote: > > Thanks for both responses. I can see what I am supposed to do, what I > don't > > understand is what is going wrong. > > > > Why when I click on the back button, does the id of my object become > > invalid? Any pointers in the wicket docs to understand this better? > > > > Regards, > > Pieter > > > > BTW> Thanks for a great framework. > > > > > > On Thu, Jan 22, 2009 at 5:44 PM, Igor Vaynberg <igor.vaynb...@gmail.com > >wrote: > > > >> 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 > >> > >> > > >