You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk> on 2008/11/25 08:25:29 UTC

SOLUTION:Hibernate Lazy initialazation issues and multi page wizard!

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


AW: ModalWindow and page serialization in 1.4RC1

Posted by Stefan Lindner <li...@visionet.de>.
Ok, thank you! So I need to rethink the design of our ModalWindows use.

Stefan

-----Ursprüngliche Nachricht-----
Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Gesendet: Dienstag, 25. November 2008 18:52
An: users@wicket.apache.org
Betreff: Re: ModalWindow and page serialization in 1.4RC1

instead of anonymous make it a private static inner class

-igor

On Tue, Nov 25, 2008 at 9:48 AM, Stefan Lindner <li...@visionet.de> wrote:
> Arghhh! Ok, so the Page object itself holds a reference to the parent class. But is there any way to suppress the serialization of this parent object?
>
> Stefan
>
> -----Ursprüngliche Nachricht-----
> Von: Matej Knopp [mailto:matej.knopp@gmail.com]
> Gesendet: Dienstag, 25. November 2008 18:43
> An: users@wicket.apache.org
> Betreff: Re: ModalWindow and page serialization in 1.4RC1
>
> On Tue, Nov 25, 2008 at 6:37 PM, Stefan Lindner <li...@visionet.de> wrote:
>> No, it does not contain any references to the outer page. I had a similar case last week, so that this was the first ascpect to investigate.
>>
>> The page looks like
>>
>>        MyPage extends WebPage {
>>                String property;
>>
>>                public void setProperty(final String value) { this.property = value }
>>
>>                public MyPage(final String property) {
>>                        this.property = property;
>>                }
>>
>>                Public MyPage() {
>>                        This("default");
>>                }
>>        }
>>
>> If I create the page with
>>
>>        setPageCreator(new ModalWindow.PageCreator() {
>>                public Page createPage() {
>>                        Page p = new MyPage("parameter");
>>                        Return p;
>>                }
>>        }
>>
>> Everything works as expected, only the components of MyPage are serialized on klicking around the page.
>>
>> If I create the page as anonymous class with
>>
>>        setPageCreator(new ModalWindow.PageCreator() {
>>                public Page createPage() {
>>                        Page p = new MyPage("parameter") {
>>                                // need nothing else to force behavior
>>                        };
>>                        Return p;
>>                }
>>        }
>>
>> All underlying pages are serialized.
>
> Of course they are. Anonymous classes create implicit reference to
> outerclass. This is normal behavior.
>
> -Matej
>
>>
>> Stefan
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Matej Knopp [mailto:matej.knopp@gmail.com]
>> Gesendet: Dienstag, 25. November 2008 15:01
>> An: users@wicket.apache.org
>> Betreff: Re: ModalWindow and page serialization in 1.4RC1
>>
>> Does your page inside modal window contain reference to outer page?
>>
>> -Matej
>>
>> On Tue, Nov 25, 2008 at 1:43 PM, Stefan Lindner <li...@visionet.de> wrote:
>>> I have a ModalWindow with a page inside it (constructed via
>>> modalWindow.setPageCreator). The page contains a lot of AjaxButtons etc.
>>>
>>> If the content page is constructed as a stateless page (new MyPage()
>>> without parameters) the page (content of modal window) gets Serialized
>>> on every klick onto any AjaxButton. OK.
>>>
>>> If the content page is NOT constructed as a stateless page (new
>>> MyPage("someString") WITH parameters) the page (content of modal window)
>>> AND the content of all underlying pages gets Serialized on every klick
>>> onto any AjaxButton.
>>>
>>> Is this the intended behavior? Is there a trick to avoid serializing all
>>> the content of pages "below" the modal window? If it is not the intended
>>> behavior, I will create a simple testcase.
>>>
>>> This is a problem for us because the underlying pages contain much data
>>> und the ModalWindow slows down in speed.
>>>
>>> Stefan
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ModalWindow and page serialization in 1.4RC1

Posted by Igor Vaynberg <ig...@gmail.com>.
instead of anonymous make it a private static inner class

-igor

On Tue, Nov 25, 2008 at 9:48 AM, Stefan Lindner <li...@visionet.de> wrote:
> Arghhh! Ok, so the Page object itself holds a reference to the parent class. But is there any way to suppress the serialization of this parent object?
>
> Stefan
>
> -----Ursprüngliche Nachricht-----
> Von: Matej Knopp [mailto:matej.knopp@gmail.com]
> Gesendet: Dienstag, 25. November 2008 18:43
> An: users@wicket.apache.org
> Betreff: Re: ModalWindow and page serialization in 1.4RC1
>
> On Tue, Nov 25, 2008 at 6:37 PM, Stefan Lindner <li...@visionet.de> wrote:
>> No, it does not contain any references to the outer page. I had a similar case last week, so that this was the first ascpect to investigate.
>>
>> The page looks like
>>
>>        MyPage extends WebPage {
>>                String property;
>>
>>                public void setProperty(final String value) { this.property = value }
>>
>>                public MyPage(final String property) {
>>                        this.property = property;
>>                }
>>
>>                Public MyPage() {
>>                        This("default");
>>                }
>>        }
>>
>> If I create the page with
>>
>>        setPageCreator(new ModalWindow.PageCreator() {
>>                public Page createPage() {
>>                        Page p = new MyPage("parameter");
>>                        Return p;
>>                }
>>        }
>>
>> Everything works as expected, only the components of MyPage are serialized on klicking around the page.
>>
>> If I create the page as anonymous class with
>>
>>        setPageCreator(new ModalWindow.PageCreator() {
>>                public Page createPage() {
>>                        Page p = new MyPage("parameter") {
>>                                // need nothing else to force behavior
>>                        };
>>                        Return p;
>>                }
>>        }
>>
>> All underlying pages are serialized.
>
> Of course they are. Anonymous classes create implicit reference to
> outerclass. This is normal behavior.
>
> -Matej
>
>>
>> Stefan
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Matej Knopp [mailto:matej.knopp@gmail.com]
>> Gesendet: Dienstag, 25. November 2008 15:01
>> An: users@wicket.apache.org
>> Betreff: Re: ModalWindow and page serialization in 1.4RC1
>>
>> Does your page inside modal window contain reference to outer page?
>>
>> -Matej
>>
>> On Tue, Nov 25, 2008 at 1:43 PM, Stefan Lindner <li...@visionet.de> wrote:
>>> I have a ModalWindow with a page inside it (constructed via
>>> modalWindow.setPageCreator). The page contains a lot of AjaxButtons etc.
>>>
>>> If the content page is constructed as a stateless page (new MyPage()
>>> without parameters) the page (content of modal window) gets Serialized
>>> on every klick onto any AjaxButton. OK.
>>>
>>> If the content page is NOT constructed as a stateless page (new
>>> MyPage("someString") WITH parameters) the page (content of modal window)
>>> AND the content of all underlying pages gets Serialized on every klick
>>> onto any AjaxButton.
>>>
>>> Is this the intended behavior? Is there a trick to avoid serializing all
>>> the content of pages "below" the modal window? If it is not the intended
>>> behavior, I will create a simple testcase.
>>>
>>> This is a problem for us because the underlying pages contain much data
>>> und the ModalWindow slows down in speed.
>>>
>>> Stefan
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: ModalWindow and page serialization in 1.4RC1

Posted by Stefan Lindner <li...@visionet.de>.
Arghhh! Ok, so the Page object itself holds a reference to the parent class. But is there any way to suppress the serialization of this parent object?

Stefan

-----Ursprüngliche Nachricht-----
Von: Matej Knopp [mailto:matej.knopp@gmail.com] 
Gesendet: Dienstag, 25. November 2008 18:43
An: users@wicket.apache.org
Betreff: Re: ModalWindow and page serialization in 1.4RC1

On Tue, Nov 25, 2008 at 6:37 PM, Stefan Lindner <li...@visionet.de> wrote:
> No, it does not contain any references to the outer page. I had a similar case last week, so that this was the first ascpect to investigate.
>
> The page looks like
>
>        MyPage extends WebPage {
>                String property;
>
>                public void setProperty(final String value) { this.property = value }
>
>                public MyPage(final String property) {
>                        this.property = property;
>                }
>
>                Public MyPage() {
>                        This("default");
>                }
>        }
>
> If I create the page with
>
>        setPageCreator(new ModalWindow.PageCreator() {
>                public Page createPage() {
>                        Page p = new MyPage("parameter");
>                        Return p;
>                }
>        }
>
> Everything works as expected, only the components of MyPage are serialized on klicking around the page.
>
> If I create the page as anonymous class with
>
>        setPageCreator(new ModalWindow.PageCreator() {
>                public Page createPage() {
>                        Page p = new MyPage("parameter") {
>                                // need nothing else to force behavior
>                        };
>                        Return p;
>                }
>        }
>
> All underlying pages are serialized.

Of course they are. Anonymous classes create implicit reference to
outerclass. This is normal behavior.

-Matej

>
> Stefan
>
>
> -----Ursprüngliche Nachricht-----
> Von: Matej Knopp [mailto:matej.knopp@gmail.com]
> Gesendet: Dienstag, 25. November 2008 15:01
> An: users@wicket.apache.org
> Betreff: Re: ModalWindow and page serialization in 1.4RC1
>
> Does your page inside modal window contain reference to outer page?
>
> -Matej
>
> On Tue, Nov 25, 2008 at 1:43 PM, Stefan Lindner <li...@visionet.de> wrote:
>> I have a ModalWindow with a page inside it (constructed via
>> modalWindow.setPageCreator). The page contains a lot of AjaxButtons etc.
>>
>> If the content page is constructed as a stateless page (new MyPage()
>> without parameters) the page (content of modal window) gets Serialized
>> on every klick onto any AjaxButton. OK.
>>
>> If the content page is NOT constructed as a stateless page (new
>> MyPage("someString") WITH parameters) the page (content of modal window)
>> AND the content of all underlying pages gets Serialized on every klick
>> onto any AjaxButton.
>>
>> Is this the intended behavior? Is there a trick to avoid serializing all
>> the content of pages "below" the modal window? If it is not the intended
>> behavior, I will create a simple testcase.
>>
>> This is a problem for us because the underlying pages contain much data
>> und the ModalWindow slows down in speed.
>>
>> Stefan
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ModalWindow and page serialization in 1.4RC1

Posted by Matej Knopp <ma...@gmail.com>.
On Tue, Nov 25, 2008 at 6:37 PM, Stefan Lindner <li...@visionet.de> wrote:
> No, it does not contain any references to the outer page. I had a similar case last week, so that this was the first ascpect to investigate.
>
> The page looks like
>
>        MyPage extends WebPage {
>                String property;
>
>                public void setProperty(final String value) { this.property = value }
>
>                public MyPage(final String property) {
>                        this.property = property;
>                }
>
>                Public MyPage() {
>                        This("default");
>                }
>        }
>
> If I create the page with
>
>        setPageCreator(new ModalWindow.PageCreator() {
>                public Page createPage() {
>                        Page p = new MyPage("parameter");
>                        Return p;
>                }
>        }
>
> Everything works as expected, only the components of MyPage are serialized on klicking around the page.
>
> If I create the page as anonymous class with
>
>        setPageCreator(new ModalWindow.PageCreator() {
>                public Page createPage() {
>                        Page p = new MyPage("parameter") {
>                                // need nothing else to force behavior
>                        };
>                        Return p;
>                }
>        }
>
> All underlying pages are serialized.

Of course they are. Anonymous classes create implicit reference to
outerclass. This is normal behavior.

-Matej

>
> Stefan
>
>
> -----Ursprüngliche Nachricht-----
> Von: Matej Knopp [mailto:matej.knopp@gmail.com]
> Gesendet: Dienstag, 25. November 2008 15:01
> An: users@wicket.apache.org
> Betreff: Re: ModalWindow and page serialization in 1.4RC1
>
> Does your page inside modal window contain reference to outer page?
>
> -Matej
>
> On Tue, Nov 25, 2008 at 1:43 PM, Stefan Lindner <li...@visionet.de> wrote:
>> I have a ModalWindow with a page inside it (constructed via
>> modalWindow.setPageCreator). The page contains a lot of AjaxButtons etc.
>>
>> If the content page is constructed as a stateless page (new MyPage()
>> without parameters) the page (content of modal window) gets Serialized
>> on every klick onto any AjaxButton. OK.
>>
>> If the content page is NOT constructed as a stateless page (new
>> MyPage("someString") WITH parameters) the page (content of modal window)
>> AND the content of all underlying pages gets Serialized on every klick
>> onto any AjaxButton.
>>
>> Is this the intended behavior? Is there a trick to avoid serializing all
>> the content of pages "below" the modal window? If it is not the intended
>> behavior, I will create a simple testcase.
>>
>> This is a problem for us because the underlying pages contain much data
>> und the ModalWindow slows down in speed.
>>
>> Stefan
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: ModalWindow and page serialization in 1.4RC1

Posted by Stefan Lindner <li...@visionet.de>.
No, it does not contain any references to the outer page. I had a similar case last week, so that this was the first ascpect to investigate.

The page looks like

	MyPage extends WebPage {
		String property;

		public void setProperty(final String value) { this.property = value }

		public MyPage(final String property) {
			this.property = property;
		}

		Public MyPage() {
			This("default");
		}
	}

If I create the page with

	setPageCreator(new ModalWindow.PageCreator() {
		public Page createPage() {
			Page p = new MyPage("parameter");
			Return p;
		}
	}

Everything works as expected, only the components of MyPage are serialized on klicking around the page.

If I create the page as anonymous class with

	setPageCreator(new ModalWindow.PageCreator() {
		public Page createPage() {
			Page p = new MyPage("parameter") {
				// need nothing else to force behavior
			};
			Return p;
		}
	}

All underlying pages are serialized.

Stefan


-----Ursprüngliche Nachricht-----
Von: Matej Knopp [mailto:matej.knopp@gmail.com] 
Gesendet: Dienstag, 25. November 2008 15:01
An: users@wicket.apache.org
Betreff: Re: ModalWindow and page serialization in 1.4RC1

Does your page inside modal window contain reference to outer page?

-Matej

On Tue, Nov 25, 2008 at 1:43 PM, Stefan Lindner <li...@visionet.de> wrote:
> I have a ModalWindow with a page inside it (constructed via
> modalWindow.setPageCreator). The page contains a lot of AjaxButtons etc.
>
> If the content page is constructed as a stateless page (new MyPage()
> without parameters) the page (content of modal window) gets Serialized
> on every klick onto any AjaxButton. OK.
>
> If the content page is NOT constructed as a stateless page (new
> MyPage("someString") WITH parameters) the page (content of modal window)
> AND the content of all underlying pages gets Serialized on every klick
> onto any AjaxButton.
>
> Is this the intended behavior? Is there a trick to avoid serializing all
> the content of pages "below" the modal window? If it is not the intended
> behavior, I will create a simple testcase.
>
> This is a problem for us because the underlying pages contain much data
> und the ModalWindow slows down in speed.
>
> Stefan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ModalWindow and page serialization in 1.4RC1

Posted by Matej Knopp <ma...@gmail.com>.
Does your page inside modal window contain reference to outer page?

-Matej

On Tue, Nov 25, 2008 at 1:43 PM, Stefan Lindner <li...@visionet.de> wrote:
> I have a ModalWindow with a page inside it (constructed via
> modalWindow.setPageCreator). The page contains a lot of AjaxButtons etc.
>
> If the content page is constructed as a stateless page (new MyPage()
> without parameters) the page (content of modal window) gets Serialized
> on every klick onto any AjaxButton. OK.
>
> If the content page is NOT constructed as a stateless page (new
> MyPage("someString") WITH parameters) the page (content of modal window)
> AND the content of all underlying pages gets Serialized on every klick
> onto any AjaxButton.
>
> Is this the intended behavior? Is there a trick to avoid serializing all
> the content of pages "below" the modal window? If it is not the intended
> behavior, I will create a simple testcase.
>
> This is a problem for us because the underlying pages contain much data
> und the ModalWindow slows down in speed.
>
> Stefan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


ModalWindow and page serialization in 1.4RC1

Posted by Stefan Lindner <li...@visionet.de>.
I have a ModalWindow with a page inside it (constructed via
modalWindow.setPageCreator). The page contains a lot of AjaxButtons etc.

If the content page is constructed as a stateless page (new MyPage()
without parameters) the page (content of modal window) gets Serialized
on every klick onto any AjaxButton. OK.

If the content page is NOT constructed as a stateless page (new
MyPage("someString") WITH parameters) the page (content of modal window)
AND the content of all underlying pages gets Serialized on every klick
onto any AjaxButton.

Is this the intended behavior? Is there a trick to avoid serializing all
the content of pages "below" the modal window? If it is not the intended
behavior, I will create a simple testcase.

This is a problem for us because the underlying pages contain much data
und the ModalWindow slows down in speed.

Stefan



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: SOLUTION:Hibernate Lazy initialazation issues and multi page wizard!

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Yup, two angles on the same stuff. It does not change the clone / 
initialize technique.

I guess I could put in a wiki tip on this?

James Carman wrote:
> I don't typically use CompoundPropertyModel (we've discussed this
> offline before) because it's too "magicy."  I find that explicitly
> creating my models helps me keep track of what's going on better.  I
> do use PropertyModels, though.  I just like to explicitly know the
> "base" that I'm dealing with when I'm using property models.
>
> On Tue, Nov 25, 2008 at 6:50 AM, Nino Saturnino Martinez Vazquez Wael
> <ni...@jayway.dk> wrote:
>   
>> 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
>>> <ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>         
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>       
>> --
>> -Wicket for love
>>
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   

-- 
-Wicket for love

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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: SOLUTION:Hibernate Lazy initialazation issues and multi page wizard!

Posted by James Carman <ja...@carmanconsulting.com>.
I don't typically use CompoundPropertyModel (we've discussed this
offline before) because it's too "magicy."  I find that explicitly
creating my models helps me keep track of what's going on better.  I
do use PropertyModels, though.  I just like to explicitly know the
"base" that I'm dealing with when I'm using property models.

On Tue, Nov 25, 2008 at 6:50 AM, Nino Saturnino Martinez Vazquez Wael
<ni...@jayway.dk> wrote:
> 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
>> <ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: SOLUTION:Hibernate Lazy initialazation issues and multi page wizard!

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
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
> <ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   

-- 
-Wicket for love

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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: SOLUTION:Hibernate Lazy initialazation issues and multi page wizard!

Posted by James Carman <ja...@carmanconsulting.com>.
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
<ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org