且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将JSTL与Facelets集成

更新时间:2023-12-04 19:30:10

Facelets已克隆 一组有限的好旧" JSTL标签,并包含在Facelets库中.在此处中都对它们进行了描述.换句话说:Facelets并不支持所有的JSTL标签/功能.

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.

如果您想使用任何原始的JSTL标记,但Facelets无法使用它,那么您将前往另一个角落寻求解决方案. JSTL sql xml 标签库不属于视图,而是属于模型/业务逻辑. JSTL fmt 标签库已被JSF的<f:loadBundle><f:formatXXX>标记覆盖. JSTL 功能标签库使用自定义EL功能可以很好地完成.我已经在

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.

JSF和原始JSTL库的问题在于它们没有像您期望的那样同步运行.更重要的是,JSTL首先从上到下运行页面,然后将生成的输出移交给JSF进行进一步处理.当使用例如<c:forEach>时,这可能会导致意外结果.

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