Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating JSTL With Facelets

Tags:

jsf

jstl

facelets

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

Are there any issues in integrating these ?

like image 322
Anand Sunderraman Avatar asked Dec 13 '22 22:12

Anand Sunderraman


2 Answers

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:

  • JSTL in JSF2 Facelets... makes sense?
like image 83
BalusC Avatar answered Dec 20 '22 12:12

BalusC


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).

like image 39
Romain Linsolas Avatar answered Dec 20 '22 11:12

Romain Linsolas