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.
>> 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.
Martijn
--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 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]