-bump-

Summary: how to disable a component and all of its children in one call?
And also: what is the expected behavior of a disabled parent component in the light of its children?

A quick look in the source of FormComponentPanel tells me that this code does not disable or enable its children when it itself is disabled or enabled.

Matthijs

PS. The onBeforeRender implementation I have (uses IVisitor to disable children) works well enough. This mail is just because I'm curious how this should be done.

Matthijs Wensveen wrote:
Hi,

I have a Panel (myPanel) containing some child components. When I say:
myPanel.setEnabled(false);
I want to disable the panel, but also disable all children.

Preferably, I'd override setEnabled, but since it is final (sigh), this is impossible. A less elegant way to do it is to supply a public setChildrenEnabled method, or something. Usually, the applications I build try to be as implementation-agnostic as possible regarding the specific component subclasses, i.e. declare myPanel as Panel or even Component where possible. In that case, classes that use myPanel don't see setChildrenEnabled unless they cast it to MyPanel.

Another way would be to override onBeforeRender and use a Component.IVisitor to call setEnabled on all children. This works, but seems to me like the wrong moment to do this. Also, it would not allow you to disable myPanel but enable some specific child (since that would be overruled in onBeforeRender of MyPanel).

I think it comes down to the semantics of setEnabled. What does it mean when a component is disabled? What does it mean to a child when its parent is disabled? (this is starting to sound like a charity ad.)

Anyways. Any ideas?



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

Reply via email to