从JSF1.2迁移到JSF2.0:如何处理JSTL? [英] Migrating from JSF1.2 to JSF2.0: What to do with JSTL?

查看:130
本文介绍了从JSF1.2迁移到JSF2.0:如何处理JSTL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将把JSF 1.2项目迁移到JSF2.我们已经在使用facelets(不是JSP)作为演示技术.

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

我们使用了大量的JSTL-> "xmlns:c="http://java.sun.com/jstl/core"

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

我们正在使用许多<c:if>语句.我知道JSF2带来了rendered属性,该属性还应该评估布尔表达式.

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

我应该麻烦将内容重写为新的呈现属性还是可以继续在JSF2中使用JSTL?

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

推荐答案

JSTL在JSF2中的工作方式与在JSF1中的工作方式相同. rendered属性不是特定于JSF2的,它在整个生命周期中一直存在于JSF中.如果这些JSTL标记始终可以在JSF 1.2应用程序中按预期工作,则不必为JSF2迁移它们.您只需更改taglib uri即可包含/jsp(!!)路径.

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"

但是,绝对推荐使用rendered属性,而不是依赖JSTL标签.确定是否计划将JSTL标记属性绑定到@ViewScoped bean.另请参见在JSF 2.0中进行通信-@ViewScoped在标记处理程序中失败.

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.

这篇关于从JSF1.2迁移到JSF2.0:如何处理JSTL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆