Sometimes, it is desirable to remove certain elements from a JSF page during development without necessarily deleting the markup. As developers we are accustomed to "commenting out" code, but standard JSF does not provide a simple way for us to remove markup without deleting it.
We can always set the rendered
attribute to false for UI components, but what if the rendered
attribute is already specified based on some EL expression? We can use HTML comments, but any EL expressions in those comments will still be evaluated, possibly resulting in runtime errors.
Facelets provides a simple solution to this problem: the<ui:remove>
tag. Any markup wrapped by the<ui:remove>
tag will literally be removed from the UI component tree at request time. The following example shows the difference between a button component that is not rendered, and a button component that is removed. In the first attempt, we set the button's rendered
attribute to false.
remove01...