4
votes

I am considering using Facelets and JSTL in the same web project.

Are there any issues in integrating these ?

2

2 Answers

10
votes

Facelets has cloned a limited set of "good old" JSTL tags and included in the Facelets library. They are all described here. In other words: not all JSTL tags/functions are supported in Facelets.

If there's any original JSTL tag which you would like to use, but isn't made available by Facelets, then you'll head in another corner for the solution. The jobs which can be done by the JSTL sql and xml taglibs doesn't belong in the view, but rather in the model/business logic. The JSTL fmt taglib is already covered by JSF's <f:loadBundle> and the <f:formatXXX> tags. The JSTL functions taglib can be as good done with custom EL functions. I've posted an example in this answer.

The problem with JSF and the original JSTL library is that they doesn't run in sync as you would expect from the coding. It's more so that JSTL runs the page from top to bottom first and then hands the generated output over to JSF for further processing. This may lead to unexpected results when using for example <c:forEach>.

See also:

3
votes

As explained in the Facelets doc here, JSTL can be integrated in Facelets application. However, some components of the JSTL library must be avoided if possible, such as <c:set> for example.

Note that Facelets also provide some replacements for JSTL tag. Thus, you can replace <c:forEach> by <ui:repeat> tag (read more here about these two components).