开发者

Integrating JSTL With Facelets

开发者 https://www.devze.com 2022-12-27 13:02 出处:网络
I am considering using Facelets and JSTL in the same web project. Are 开发者_如何学Gothere any issues in integrating these ?Facelets has cloned a limited set of "good old" JSTL tags and inc

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

Are 开发者_如何学Gothere any issues in integrating these ?


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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消