blob: ccd030d7f6b88178d4c1d9bd7fc98c4a7bfc7f31 [file] [log] [blame]
At the end of the previous chapter we have seen how to hide a component calling its method _setVisible_. In a similar fashion, we can also decide to disable a component using method _setEnabled_. When a component is disabled all the links inside it will be in turn disabled (they will be rendered as _<span>_) and it can not fire JavaScript events.
Class _Component_ provides two getter methods to determine if a component is visible or enabled: _isVisible_ and _isEnabled_.
Even if nothing prevents us from overriding these two methods to implement a custom logic to determine the state of a component, we should keep in mind that methods _isVisible_ and _isEnabled_ are called multiple times before a component is fully rendered. Hence, if we place non-trivial code inside these two methods, we can sensibly deteriorate the responsiveness of our pages.
WARNING: Overriding _isVisible_ or _isEnabled_ can lead to unpredictable results when querying visibility information via _isVisibleInHierarchy_ or _isEnabledInHierarchy_.
As we will see in the next chapter, class _Component_ provides method _onConfigure_ which is more suited to contain code that contributes to determine component states because it is called just once during rendering phase of a request.