1

Is there any reason not to use c:if over the rendered attribute? When I started learning jsf the general vibe I got from the tutorials I read was that jstl tags should be forgotten. So everytime I use a jstl tag I feel like I'm doing something wrong.

However for c:if, it is executed at build time while rendered jsf attribute is executed at rendering time (explanation here). It looks like a waste to me to add something to the component tree if it's not to be rendered afterwards. Better not adding it at all using c:if, amiright?

For example on a all my pages, I've an admin menu that is included if the user is admin. I see no reason to add the menu to the tree if it's not to display it when page is rendered. So I just use c:if there. I use rendered on small parts when it's more convenient or for ajax type things.

Community
  • 1
  • 1
Ced
  • 15,847
  • 14
  • 87
  • 146
  • Generally people avoid using things they couldn't explain/understand. I'd put question marks around the tutorials written by those people. – BalusC Aug 17 '15 at 20:19
  • @BalusC My worry was a possible performance loss because the component tree has to be recalculated. The javadoc isn't really clear whether the tree is recalculated each time or not during the restore view when using jsf tags but it would make sens to store it instead, making it faster. – Ced Aug 17 '15 at 22:06
  • Measuring is knowing. It depends on a lot of things (model, composition, etc, also specific JSF impl/version). But generally, the theory (and practice) is indeed that view build time is way much faster. – BalusC Aug 18 '15 at 08:33

0 Answers0