You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Matthijs Wensveen <m....@func.nl> on 2007/10/10 08:58:31 UTC
enable / disable MarkupContainer and all children
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?
--
Matthijs Wensveen
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: enable / disable MarkupContainer and all children
Posted by Matthijs Wensveen <m....@func.nl>.
-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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org