I guess not much if you do the initialize, but it has some issues with collections (like you need to add to collections instead of setting them I think). And you will end up doing initialize anyhow so using clone and a simple compound property model are just as fine plus more simple..

James Carman wrote:
So, what's wrong with using "shadow" models and letting them
eventually write into the real model (which is a LDM) at the very end?

On Tue, Nov 25, 2008 at 2:25 AM, Nino Saturnino Martinez Vazquez Wael
<[EMAIL PROTECTED]> wrote:
Hi Guys

I've been having a little trouble with hibernate and a multipage wizard, I
finally cracked the nut. And heres my solution:

In the link that refers to the wizard use a loadable detachable model..
Onclick you initialize all proper collections and CLONE the object, after
the wizard are done you merge the clone..

codesniplet:

              Link<Event> linkEdit = new Link<Event>("edit",
item.getModel()) {
                  @Override
                  public void onClick() {
                      LoadableDetachableEventModel model=new
LoadableDetachableEventModel(eventRepository,this.getModelObject());

Hibernate.initialize(((Event)model.getObject())
                              .getLinks());
                      Hibernate.initialize(((Event)model.getObject())
                              .getDateStart());
                      Hibernate.initialize(((Event)model.getObject())
                              .getDateEnd());
                      Hibernate.initialize(((Event)model.getObject())
                              .getTags());

                      Model<Event> eventModel = new Model<Event>(
                              (Event) SerializationHelper.clone((Event)
model.getObject()));
                      CompoundPropertyModel<Event> e = new
CompoundPropertyModel<Event>(
                              eventModel);
                      EventWizard newWizard = new EventWizard(eventWizard
                              .getId(), e) {
                          @Override
                          public void onFinish() {

eventRepository.update(eventModel.getObject());
                              eventWizard.setVisible(false);
                          }
                      };
                      newWizard.setVisible(true);
                      eventWizard.getPage().addOrReplace(newWizard);
                      eventWizard = newWizard;

                  }
              };


--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to