Migrating from JSF1.2 to JSF2.0: What to do with JSTL?

此生再无相见时 提交于 2019-12-11 10:05:41

问题


we are going to migrate our JSF 1.2 project to JSF 2. We are already using facelets (not JSPs) as our presentation technology.

We are using lot of JSTL -> "xmlns:c="http://java.sun.com/jstl/core"

We are using lot of <c:if> statements. I know that JSF2 brings rendered attribute, which should also evaluate boolean expressions.

Should I bother rewriting stuff to new rendered attribute or is it ok to continue using JSTL in JSF2?


回答1:


JSTL works the same way in JSF2 as it worked in JSF1. The rendered attribute is not JSF2 specific, it has been in JSF all the lifetime long. If those JSTL tags have always worked as intended in your JSF 1.2 application, then you don't necessarily need to migrate them for JSF2. You only need to change the taglib uri to include the /jsp (!!) path.

xmlns:c="http://java.sun.com/jsp/jstl/core"

However, whenever possible, using the rendered attribute definitely is more recommended than relying on JSTL tags. For sure if you plan to bind JSTL tag attributes to a @ViewScoped bean. See also Communication in JSF 2.0 - @ViewScoped fails in taghandlers.



来源:https://stackoverflow.com/questions/7726523/migrating-from-jsf1-2-to-jsf2-0-what-to-do-with-jstl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!