Re: How to enable/disable an hierarchy?
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?
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
Re: How to enable/disable an hierarchy?
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
Re: How to enable/disable an hierarchy?
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