On Wed, Aug 20, 2008 at 12:39 PM, Martijn Dashorst <[EMAIL PROTECTED]> wrote: > On Wed, Aug 20, 2008 at 6:27 PM, James Carman > <[EMAIL PROTECTED]> wrote: >> If you don't commit the changes (and you wouldn't want to typically in >> a wizard) to the object between "pages", then the original data will >> merely be loaded from the database and your previous edits will be >> lost. > > erhm... yes–when the form doesn't repeat that data. Didn't think of that.
Yeah, presumably different pages would edit different parts of the same object (for a person you might have a page for first name, last name and another page for address information). > >>> This discussion is of course completely moot when you don't have a >>> persistent entity as your model for the wizard. >> >> Of course, but then again why would you be using LDM if you're not >> editing a persistent entity? > > public class EntityModel<T> extends LoadableDetachableModel { > private Class<T> clazz; > private Long id; > > public EntityModel(T obj) { > super(obj); > id = obj.getId(); // needs some casting) > clazz = obj.getClass(); > } > protected Object load() { > if(id != null) { > return session.get(clazz, id); > else > return new T(); > } > } > > Of course this needs the appropriate casting, measures against type erasure. > > The idea is convenience: no need to invoke different constructors or > different model chains, just pass in the EntityModel with your object, > no matter if it is persistent or not. > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]