Done

WICKET-4323

Best regards
Einar

Den 4. jan. 2012 kl. 09:49 skrev "Martin Grigorov" <mgrigo...@apache.org>:

> Hi,
> 
> Explained this way it looks like a bug indeed.
> File a ticket. If you find the differences in SRM in 1.4 vs. 1.5 then
> please attach a patch too.
> Thanks!
> 
> On Wed, Jan 4, 2012 at 10:44 AM, Einar Bjerve <einar.bje...@visma.no> wrote:
>> Hi,
>> 
>> Well, StringResourceModel#detach() is called, but since the SRM isn't 
>> attached, StringResourceModel#onDetach() is never called and the result is 
>> that the property substitution model isn't detached. I'll demonstrate with a 
>> bit of code:
>> 
>> 
>> IModel substitutionModel1 = ...;
>> IModel substitutionModel2 = ...;
>> 
>> add( new Label( "id1", new StringResourceModel( "resourceKey1", getPage(), 
>> substitutionModel1) ) ); // substitutionModel1 detaches properly
>> add( new Label( "id2", new StringResourceModel( "resourceKey2", 
>> substitutionModel2) ) ); // substitutionModel2 never detaches
>> 
>> 
>> In the above snippet, substitutionModel1 will be detached, but 
>> substitutionModel2 will not be detached when its label is detached. In 1.4.x 
>> both substitutionmodels would be detached
>> 
>> The reason this happens is that StringResourceModel is wrapped on assignment 
>> in a StringResourceModel.AssignmentWrapper. This assignmentwrapper never 
>> calls StringResourceModel#getObject() if the component constructor argument 
>> is null. In 1.4 StringResourceModel#getObject() would always be called 
>> (which means load() is called, and the enclosing SRM is attached).
>> 
>> The result is that the AssignmentWrapper is attached, but the enclosing 
>> StringResourceModel isn't. When 
>> StringResourceModel.AssignmentWrapper#detach() attempts to calls 
>> StringResourceModel#detach() the if(!attached) test (in StringResourceModel 
>> #detach()) returns false, which results in that 
>> StringResourceModel#onDetach() is never called.
>> 
>> Since detaching of property substitution models and detachable parameters is 
>> done in StringResourceModel#onDetach(), these objects won't be detached.
>> 
>> 
>> I believe this is a bug, as it was changed between 1.4 and 1.5. In 1.4 it 
>> was consistent, in 1.5 it isn't.
>> 
>> 
>> Best regards
>> Einar Bjerve
>> 
>> 
>> -----Opprinnelig melding-----
>> Fra: Martin Grigorov [mailto:mgrigo...@apache.org]
>> Sendt: 3. januar 2012 16:36
>> Til: users@wicket.apache.org
>> Emne: Re: StringResourceModels doesn't seem to detach properly
>> 
>> Hi,
>> 
>> It is intended.
>> IModel#detach() is called only if this model is assigned to a component.
>> Since no one calls #detach() on the StringResourceModel it has no idea
>> when to call detach() on its inner model.
>> You need to call SRM.detach() in #onDetach() in the component where it
>> is used. Then it will detach its inner model too.
>> 
>> On Tue, Jan 3, 2012 at 5:30 PM, Einar Bjerve <einar.bje...@visma.no> wrote:
>>> If a StringResourceModel contains a model for property substitutions, and 
>>> there has not been assigned a component it is relative to on construction 
>>> time, it will not detach the property substitution model.
>>> 
>>> If there is assigned a component on construction time, the property 
>>> substitution model is detached with the StringResourceModel.
>>> 
>>> This behavior seems kind of inconsistent to me. Is this intended and 
>>> correct?
>>> 
>>> 
>>> Best regards
>>> Einar Bjerve
>> 
>> 
>> 
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>> 
> 
> 
> 
> -- 
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 

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

Reply via email to