SV: StringResourceModels doesn't seem to detach properly

2012-01-04 Thread Einar Bjerve
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



Re: StringResourceModels doesn't seem to detach properly

2012-01-04 Thread Einar Bjerve
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



StringResourceModels doesn't seem to detach properly

2012-01-03 Thread Einar Bjerve
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


Re: Ajax and ModalWindow Strange behaviour

2010-12-04 Thread Einar Bjerve
Could it be that the modalwindow detaches your models when it closes? 
 
Den 3. des. 2010 kl. 15.22 skrev Poko Booth:

 Hmmm.. Turns out it's not the modal window the one causing the problem.
 The modal was activated by an ajaxsubmitlink and the page form had required
 components thus errors took place.
 I changed those links to ajaxlinks and the problem now appears only after
 the user submits the page form with required errors.
 Is this the normal behavior?
 
 On Fri, Dec 3, 2010 at 4:12 PM, Poko Booth poko.bo...@gmail.com wrote:
 
 Nope...Just tried that, same result. I can't understand why
 components.modalChanged() fixes this problematic behavior... Why is the
 modal window messing with the parent page's components model???
 
 Thanx for the answer though, you were too fast, thought it would be it :)
 
 
 On Fri, Dec 3, 2010 at 3:58 PM, Martin Makundi 
 martin.maku...@koodaripalvelut.com wrote:
 
 Maybe this:
 http://www.mail-archive.com/users@wicket.apache.org/msg35946.html
 
 **
 Martin
 
 2010/12/3 Poko Booth poko.bo...@gmail.com:
 Hi all, here's the case:
 
 I have an object, let's say a, which has a member b which has two
 members:
 owner and driver of same type.
 In a page I have a checkbox which when being pressed, sets driver =
 owner
 and the opposite and I have the components bellow:
 
 TextFieldString ownerName with PropertyModel(a,b.owner.firstname);
 TextFieldString driverName with PropertyModel(a,b.driver.firstname);
 
 When the checkbox is pressed [true] the driverName component is
 disabled.
 The checkbox has an ajax event behavior to do the job/rerendering of the
 appropriate components.
 So far so good.
 
 I have a modal window in the page at another point and after I
 open/close it
 [without messing with the b object at all] the checkbox's behiavior
 becomes weird.
 When the driverName is rerendered, it has no value. The driverName was
 one
 of 20 components that need to be rerendered. Before openening the modal
 window everything works fine, after I close it the inputs are being
 drawn
 with empty strings instead of the real values.
 *If I call driverName.modelChanged() in the checkbox's ajax event
 behavior
 then everything goes as expected.
 Why is that?*
 
 
 Any ideas?
 Thanx,
 Poko
 
 
 -
 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



Re: How to enable/disable an hierarchy?

2010-12-01 Thread Einar Bjerve
Using onConfigure doesn't help much. If I disable the common parent, and
call setEnabled in onConfigure in the few components I want visible, the
components will still be disabled during the rendering phase because
onComponentTag calls isEnabledInHierarchy.

I could override onConfigure in every component, and read the field that
controls the enabling/disabling, but that would create a lot of boilerplate
code for the 80-90% of FormComponents/links that should be disabled. It
would be a lot cleaner to disable the parent, and only handle the ones I
want enabled.

--einar

On Wed, Dec 1, 2010 at 1:21 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote:

 have a field in the page that controls whether or not these components
 should be enabled/disabled, then override their onconfigure() methods
 and setenable/disabled based on the field.

 -igor

 On Tue, Nov 30, 2010 at 3:17 PM, Einar Bjerve einar.bje...@gmail.com
 wrote:
  Hi all,
 
  How can we enable/disable almost an entire hierarchy under certain
  circumstances, while still keeping some of them open for
 editing/clicking?
 
  The obvious solution would be to enable/disable the ancestor and override
  isEnabledInHierarchy for the few components that should still be enabled,
  but it's final so can't do that.
 
  We also tried writing a behavior that traversed all children and set the
  affected FormComponents/Links to disabled. But that didn't work either.
 We
  can't do it in beforeRender() because the render phase has started when
 it
  is called and then setDisabled will fail. And we can't do it in bind()
 since
  some of the children to be disabled is FormComponents in a DataView, and
  children of a DataView isn't added until onBeforeRender - so they aren't
  available yet.
 
  Overriding isEnabled in every component that should be disabled isn't
 really
  an option either, due to the amount of components affected.
 
  Any suggestions?
 

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




Re: How to enable/disable an hierarchy?

2010-12-01 Thread Einar Bjerve
Thanks, finally got it to work.

By overriding parentPanel.onBeforeRender(), and visit the children I was
able to enable/disable child components. It is important to call
super.onBeforeRender() before visiting children to populate the ListView
first.

I could not use onConfigure() because some of the components that should be
enabled/disabled is part of a ListView, and the ListView isn't populated yet
when onConfigure is called.

-- Einar

On Wed, Dec 1, 2010 at 11:12 AM, Wilhelmsen Tor Iver toriv...@arrive.nowrote:

  I could override onConfigure in every component, and read the field that
  controls the enabling/disabling, but that would create a lot of
 boilerplate
  code for the 80-90% of FormComponents/links that should be disabled. It
  would be a lot cleaner to disable the parent, and only handle the ones I
  want enabled.

 Sounds like you want to use a Component.IVisitor on the parent, which deals
 with enanbling/disabling subcomponents based on some state.

 - Tor Iver


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




How to enable/disable an hierarchy?

2010-11-30 Thread Einar Bjerve
Hi all,

How can we enable/disable almost an entire hierarchy under certain
circumstances, while still keeping some of them open for editing/clicking?

The obvious solution would be to enable/disable the ancestor and override
isEnabledInHierarchy for the few components that should still be enabled,
but it's final so can't do that.

We also tried writing a behavior that traversed all children and set the
affected FormComponents/Links to disabled. But that didn't work either. We
can't do it in beforeRender() because the render phase has started when it
is called and then setDisabled will fail. And we can't do it in bind() since
some of the children to be disabled is FormComponents in a DataView, and
children of a DataView isn't added until onBeforeRender - so they aren't
available yet.

Overriding isEnabled in every component that should be disabled isn't really
an option either, due to the amount of components affected.

Any suggestions?


Re: how Translate SingIn panel...

2010-09-15 Thread Einar Bjerve
As far as I know SigninPanel only partially support localization, so you have 
to override SigninPanel, and provide your own html with the correct translation.

And you should probably add signInFailed to your properties so you get that 
message in your language too

Einar

Den 15. sep. 2010 kl. 21.59 skrev Victor_Trapiello:

 
 Hello guys, 
 
 I´m using the signIn Panel in my application, it works great but I would
 like to translate it to Spanish, I mean I would like to see Nombre de
 Usuario and Contraseña instead of UserName and password how can I do
 that¿? any Ideas¿? property files, modifing something in the wicket
 sources¿? .
 
 Tank you very much guys
 
 Victor Trapiello
 Software Engineer
 www.trapiello.net
 -- 
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/how-Translate-SingIn-panel-tp2541131p2541131.html
 Sent from the Users forum mailing list archive at Nabble.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