C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

JSTL in JSF2 Facelets makes sense?

0 votes
1,289 views
asked Jan 21, 2014 by john Guru (27,140 points)

2 Answers

0 votes
JSTL tags are taghandlers and they are executed during view build time, while JSF UI components are executed during view render time. Note that JSF's own <f:yyy> and <ui:yyy> tags which do not extend UIComponent (i.e. everything except of <f:param> and <f:selectItem(s)> and all those tags having a rendered attribute) are also taghandlers. Also, the id and binding attributes of JSF UI components are evaluated during view build time.

The view build time is that moment when the XHTML/JSP file is to be parsed and converted to a JSF component tree which is then stored as UIViewRoot of the FacesContext. The view render time is that moment when the JSF component tree is about to generate HTML, starting with UIViewRoot#encodeAll(). So: JSF UI components and JSTL tags doesn't run in sync as you'd expect from the coding. You can visualize it as follows: JSTL runs from top to bottom first, producing the JSF component tree, then it's JSF's turn to run from top to bottom again, producing the HTML output. This may lead to unexpected results when using JSTL tags in for example JSF iterating components like <h:dataTable>, <ui:repeat>, etc, or when JSTL tag attributes depend on results of JSF events like preRenderView or submitted form values in the model.
answered Jan 21, 2014 by sara Guru (24,570 points)
0 votes
As to your concrete functional requirement, if you want to render JSF components conditionally, use the rendered attribute on the JSF HTML component instead.

<h:someComponent rendered="#{lpc.verbose}">

    ...

</h:someComponent>
answered Jan 21, 2014 by keem Expert (13,240 points)

Related questions

0 votes
1 answer 37 views
37 views asked Jan 24, 2014 by sara Guru (24,570 points)
0 votes
1 answer 26 views
26 views asked Jan 21, 2014 by john Guru (27,140 points)
0 votes
1 answer 13 views
13 views asked Jan 3, 2014 by smith Geek (15,340 points)
0 votes
1 answer 75 views
...