You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Makundi <ma...@koodaripalvelut.com> on 2009/07/28 17:44:31 UTC

reuseitems problems

Hi!

I am having trouble with listView.setReuseitems(true).

My problem is that
1. on first request the listview creates form components.
2. on second (or third ...) request the listView reuses the form components.
3. however, the propertymodels attached to the formcomponents at 1 are
no longer viable, because their target objects are only the orignal
serialization copies. In state 2 or 3 the form components now update
totally obsolete instances of the target objects .

A better strategy would probably be to just copy the rawInput states
of the formComponents instead of really reusing the components.

Comments, anybody? Did I misunderstand something? I have been
debugging this for 6 hours now, maybe my brain melted down already. ..

**
Martin

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


Re: reuseitems problems

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
It might also be that it is wickettester related problem, maybe
something goes somehow wrong there. I will try to make a quickstart.

**
Martin

2009/7/29 Vladimir K <ko...@gmail.com>:
>
> Hmm ... i can imagine the only case - somewhere resolveObject() method is
> called during deserialization.
> But I'm afraid your code don't have such a method and the cause is
> different.
>
>
> MartinM wrote:
>>
>> I do not know exactly what happens, but if I run the debugger I can
>> see thet the page seen by the formcomponents' propertymodels is in a
>> different state than the one actually holding the form components.
>>
>> I wonder if ajax has something to do with this, because only part of
>> the page is refreshed via ajax. Maybe the parent page and the
>> refreshed ajax panel remain in different serialization graphs?
>>
>> **
>> Martin
>>
>> 2009/7/28 Vladimir K <ko...@gmail.com>:
>>>
>>> trying to undertand what is happening in your case. When the page is
>>> serialized the steam contains the whole graph, including the ListView and
>>> it's items and the page default model and the ListView items models. When
>>> the page is deserialized, the whole graph is restored including page, its
>>> model, items and their models. My understanding is that in your case the
>>> items models are the old ones that was in the previous version of the
>>> page,
>>> how could it be? Or I didn't get what you were saying.
>>>
>>>
>>> MartinM wrote:
>>>>
>>>> Or session store.. anyways, that's not relevant. The important fact is
>>>> that the copies are different.
>>>>
>>>> **
>>>> Martin
>>>>
>>>> 2009/7/28 Martin Makundi <ma...@koodaripalvelut.com>:
>>>>>> why do you get Page instance 2 on page refresh?
>>>>>
>>>>> Wicket always deserializes page state from diskstore.. so it is a copy.
>>>>>
>>>>> **
>>>>> Martin
>>>>>
>>>>>>
>>>>>>
>>>>>> MartinM wrote:
>>>>>>>
>>>>>>>> please describe the context. I don
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/reuseitems-problems-tp24702133p24705851.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/reuseitems-problems-tp24702133p24708835.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: reuseitems problems

Posted by Vladimir K <ko...@gmail.com>.
Hmm ... i can imagine the only case - somewhere resolveObject() method is
called during deserialization.
But I'm afraid your code don't have such a method and the cause is
different.


MartinM wrote:
> 
> I do not know exactly what happens, but if I run the debugger I can
> see thet the page seen by the formcomponents' propertymodels is in a
> different state than the one actually holding the form components.
> 
> I wonder if ajax has something to do with this, because only part of
> the page is refreshed via ajax. Maybe the parent page and the
> refreshed ajax panel remain in different serialization graphs?
> 
> **
> Martin
> 
> 2009/7/28 Vladimir K <ko...@gmail.com>:
>>
>> trying to undertand what is happening in your case. When the page is
>> serialized the steam contains the whole graph, including the ListView and
>> it's items and the page default model and the ListView items models. When
>> the page is deserialized, the whole graph is restored including page, its
>> model, items and their models. My understanding is that in your case the
>> items models are the old ones that was in the previous version of the
>> page,
>> how could it be? Or I didn't get what you were saying.
>>
>>
>> MartinM wrote:
>>>
>>> Or session store.. anyways, that's not relevant. The important fact is
>>> that the copies are different.
>>>
>>> **
>>> Martin
>>>
>>> 2009/7/28 Martin Makundi <ma...@koodaripalvelut.com>:
>>>>> why do you get Page instance 2 on page refresh?
>>>>
>>>> Wicket always deserializes page state from diskstore.. so it is a copy.
>>>>
>>>> **
>>>> Martin
>>>>
>>>>>
>>>>>
>>>>> MartinM wrote:
>>>>>>
>>>>>>> please describe the context. I don
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/reuseitems-problems-tp24702133p24705851.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/reuseitems-problems-tp24702133p24708835.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: reuseitems problems

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
I do not know exactly what happens, but if I run the debugger I can
see thet the page seen by the formcomponents' propertymodels is in a
different state than the one actually holding the form components.

I wonder if ajax has something to do with this, because only part of
the page is refreshed via ajax. Maybe the parent page and the
refreshed ajax panel remain in different serialization graphs?

**
Martin

2009/7/28 Vladimir K <ko...@gmail.com>:
>
> trying to undertand what is happening in your case. When the page is
> serialized the steam contains the whole graph, including the ListView and
> it's items and the page default model and the ListView items models. When
> the page is deserialized, the whole graph is restored including page, its
> model, items and their models. My understanding is that in your case the
> items models are the old ones that was in the previous version of the page,
> how could it be? Or I didn't get what you were saying.
>
>
> MartinM wrote:
>>
>> Or session store.. anyways, that's not relevant. The important fact is
>> that the copies are different.
>>
>> **
>> Martin
>>
>> 2009/7/28 Martin Makundi <ma...@koodaripalvelut.com>:
>>>> why do you get Page instance 2 on page refresh?
>>>
>>> Wicket always deserializes page state from diskstore.. so it is a copy.
>>>
>>> **
>>> Martin
>>>
>>>>
>>>>
>>>> MartinM wrote:
>>>>>
>>>>>> please describe the context. I don
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/reuseitems-problems-tp24702133p24705851.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: reuseitems problems

Posted by Vladimir K <ko...@gmail.com>.
trying to undertand what is happening in your case. When the page is
serialized the steam contains the whole graph, including the ListView and
it's items and the page default model and the ListView items models. When
the page is deserialized, the whole graph is restored including page, its
model, items and their models. My understanding is that in your case the
items models are the old ones that was in the previous version of the page,
how could it be? Or I didn't get what you were saying.


MartinM wrote:
> 
> Or session store.. anyways, that's not relevant. The important fact is
> that the copies are different.
> 
> **
> Martin
> 
> 2009/7/28 Martin Makundi <ma...@koodaripalvelut.com>:
>>> why do you get Page instance 2 on page refresh?
>>
>> Wicket always deserializes page state from diskstore.. so it is a copy.
>>
>> **
>> Martin
>>
>>>
>>>
>>> MartinM wrote:
>>>>
>>>>> please describe the context. I don
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/reuseitems-problems-tp24702133p24705851.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: reuseitems problems

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Or session store.. anyways, that's not relevant. The important fact is
that the copies are different.

**
Martin

2009/7/28 Martin Makundi <ma...@koodaripalvelut.com>:
>> why do you get Page instance 2 on page refresh?
>
> Wicket always deserializes page state from diskstore.. so it is a copy.
>
> **
> Martin
>
>>
>>
>> MartinM wrote:
>>>
>>>> please describe the context. I don
>

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


Re: reuseitems problems

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
> why do you get Page instance 2 on page refresh?

Wicket always deserializes page state from diskstore.. so it is a copy.

**
Martin

>
>
> MartinM wrote:
>>
>>> please describe the context. I don

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


Re: reuseitems problems

Posted by Vladimir K <ko...@gmail.com>.
Martin,

why do you get Page instance 2 on page refresh?


MartinM wrote:
> 
>> please describe the context. I don't see how the process of serialization
>> makes the instance of the object obsolete.
> 
> 1. Page instantiation. Page instance 1 {manipulating target data 1},
> formComponent instance 1->target data instance 1.
> 2. Ajax request or similar onto page.
> 3. Page refresh (deserialized from diskstore). Page instance 2
> {manipulating target data instance 2}, reused formComponent instance
> 1->target data instance 1.
> 
> So in stage 3 the page is manipulating target data instance 2 while
> the reused form components still manipulate target data instance 1.
> 
> What this means? It means that  for example if you Submit form, the
> values will be updated onto target data 1. The mistake is that if your
> Page instance 2 handles saving procedure, it will save the target data
> {2} which does not receive the form submit.
> 
> This might work differently with detached models. I do not bother with
> detached models on lightweight models.
> 
> **
> Martin
> 
>>
>> MartinM wrote:
>>>
>>> Hi!
>>>
>>> I am having trouble with listView.setReuseitems(true).
>>>
>>> My problem is that
>>> 1. on first request the listview creates form components.
>>> 2. on second (or third ...) request the listView reuses the form
>>> components.
>>> 3. however, the propertymodels attached to the formcomponents at 1 are
>>> no longer viable, because their target objects are only the orignal
>>> serialization copies. In state 2 or 3 the form components now update
>>> totally obsolete instances of the target objects .
>>>
>>> A better strategy would probably be to just copy the rawInput states
>>> of the formComponents instead of really reusing the components.
>>>
>>> Comments, anybody? Did I misunderstand something? I have been
>>> debugging this for 6 hours now, maybe my brain melted down already. ..
>>>
>>> **
>>> Martin
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/reuseitems-problems-tp24702133p24704253.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/reuseitems-problems-tp24702133p24705518.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: reuseitems problems

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
> please describe the context. I don't see how the process of serialization
> makes the instance of the object obsolete.

1. Page instantiation. Page instance 1 {manipulating target data 1},
formComponent instance 1->target data instance 1.
2. Ajax request or similar onto page.
3. Page refresh (deserialized from diskstore). Page instance 2
{manipulating target data instance 2}, reused formComponent instance
1->target data instance 1.

So in stage 3 the page is manipulating target data instance 2 while
the reused form components still manipulate target data instance 1.

What this means? It means that  for example if you Submit form, the
values will be updated onto target data 1. The mistake is that if your
Page instance 2 handles saving procedure, it will save the target data
{2} which does not receive the form submit.

This might work differently with detached models. I do not bother with
detached models on lightweight models.

**
Martin

>
> MartinM wrote:
>>
>> Hi!
>>
>> I am having trouble with listView.setReuseitems(true).
>>
>> My problem is that
>> 1. on first request the listview creates form components.
>> 2. on second (or third ...) request the listView reuses the form
>> components.
>> 3. however, the propertymodels attached to the formcomponents at 1 are
>> no longer viable, because their target objects are only the orignal
>> serialization copies. In state 2 or 3 the form components now update
>> totally obsolete instances of the target objects .
>>
>> A better strategy would probably be to just copy the rawInput states
>> of the formComponents instead of really reusing the components.
>>
>> Comments, anybody? Did I misunderstand something? I have been
>> debugging this for 6 hours now, maybe my brain melted down already. ..
>>
>> **
>> Martin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/reuseitems-problems-tp24702133p24704253.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: reuseitems problems

Posted by Vladimir K <ko...@gmail.com>.
Martin,

please describe the context. I don't see how the process of serialization
makes the instance of the object obsolete.

In my practice I use a detachable model when rendering View page and I use a
static model when rendering an Edit page. In onSubmit method I save the
model object and forward the user to the View page.


MartinM wrote:
> 
> Hi!
> 
> I am having trouble with listView.setReuseitems(true).
> 
> My problem is that
> 1. on first request the listview creates form components.
> 2. on second (or third ...) request the listView reuses the form
> components.
> 3. however, the propertymodels attached to the formcomponents at 1 are
> no longer viable, because their target objects are only the orignal
> serialization copies. In state 2 or 3 the form components now update
> totally obsolete instances of the target objects .
> 
> A better strategy would probably be to just copy the rawInput states
> of the formComponents instead of really reusing the components.
> 
> Comments, anybody? Did I misunderstand something? I have been
> debugging this for 6 hours now, maybe my brain melted down already. ..
> 
> **
> Martin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/reuseitems-problems-tp24702133p24704253.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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