• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

is jstl c:if tag better than rendered attribute of JSF???

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please comment..

Thanks
Akash
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.

I've written more JSF apps than I can count over the last couple of years and not used JSTL in any of them. Partly because in earlier JSF releases JSTL didn't play well with JSF, partly because the JSF equivalents are usually more compact, and partly because JSTL makes it too easy to start sliding controller logic into the view and thus muddy the maintainability of the webapp.

JSTL doesn't track the JSF document tree the way that JSF components do, so there's always potential for confusion. This is especially true when you conditionally include/exclude/iterate items.
 
Ranch Hand
Posts: 99
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm kinda bumping this old topic because it's one of the first I get if I do a google search rendered vs c:if.

Render attribute is executed at render time and c:if at build time. The confusion that Tim was talking about is about the view build time and the render phase. So as long as one understands that there shouldn't be any problem.

The gist I get from a detailed answer from balusC here :http://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense, is that when the view is gonna be static it is better to use c:if tag. The reason is that since the render tag happens at render time, the UIComponents are gonna be added to the render tree, which is not needed in a static page.

For example


Would be better than



As long as the page isn't supposed to update the connection of the user through ajax.
 
Tim Holloway
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm afraid I'm going to have to be dogmatic here. While I have seen JSF examaples on Oracle's website where they use JSTL, in actual practice, it's more trouble than it's worth.

I have absolutely zero JSTL in my webapps and don't miss it - JSF has native constructs that do the job as well or better.

A more salient point, however, is that JSTL is designed as a tag library for JSPs. JSPs are translated to Java Servlets, then the Servlets are compiled. A "c:if" tag translates directly into a Java "if" statement.

But JSF doesn't use JSPs. The JSF View Template language is not compiled into code, it's digested into a data tree. Data shouldn't be logic. If you have a need for an "if" tag that cannot be served by a native JSF construct, the probability is very high that you are muddling the Separation of Concerns between Model, View, and Controller and that frequently translates to "maintenance headache".

Another reason to steer clear of JSTL is that JSF may become even more detached from code-like behavior in its View handling in future releases, which means that JSTL-based stuff could break.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic