澄清对 JSF 2.0 的理解

发布于 2024-10-15 07:51:00 字数 381 浏览 2 评论 0原文

在深入研究 JSF 2.0 之前,我想通过查找以下问题的答案来澄清我对 JSF 2.0 的理解:

  1. 参考实现与 MyFaces 之间有什么区别?

  2. 带有参考实现或 MyFaces 的 jsf 2.0 可以部署在任何 servlet 上吗 容器,即 tomcat/jetty,还是必须仅部署在符合 Java EE 的容器上?

  3. 创建自定义标签有多困难?例如,类似于 Grails 中可用的分页链接标记?

  4. 是否可以将 *Faces(即 PrimeFaces、RichFaces 等)与 jquery 或 yui 等 javascript 库一起使用?这样做是否会产生任何冲突?

Before I delve into JSF 2.0 I want to clarify my understanding of JSF 2.0 by finding answers to the following:

  1. What are the differences between the reference implementation and MyFaces?

  2. Can jsf 2.0 with either reference implementation or MyFaces be deployed on any servlet
    container, i.e. tomcat/jetty, or must it be deployed only on a Java EE compliant container?

  3. How difficult is it to create custom tags? For example a pagination link tag, similar to what is available in Grails?

  4. Is it possible to use *Faces (i.e. PrimeFaces, RichFaces, etc) with a javascript library like jquery or yui? Are any conflicts created by doing so?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零崎曲识 2024-10-22 07:51:00

1:参考实现和 MyFaces 之间有什么区别?

它们是由不同的团队开发的。由于两者都应该遵守 JSF 2.0 规范,因此 应该与 JSF 2.0 规范中指定的基本功能没有区别。然而,对于暴露的和修复的错误,可能存在差异。我个人更喜欢 Mojarra(参考实现)。

2:具有参考实现或 MyFaces 的 jsf 2.0 是否可以部署在任何 servlet 容器(即 tomcat/jetty)上,还是必须仅部署在符合 Java EE 的容器上?

是的。 JSF 2.0 至少需要 Servlet 2.5 API。因此任何 Servlet 2.5 兼容容器甚至 Java EE 5 应用程序服务器就足够了。每当您想要使用 JSF 2.0 时,您可能只需要禁用 Java EE 5 应用程序服务器中的内置 JSF 1.2 API。或者,更好的是,只使用 Java EE 6 应用程序服务器(Glassfish 3、JBoss AS 6 等),因为它已经随 JSF 2.0 一起提供。

3:创建自定义标签有多困难?例如,类似于 Grails 中可用的分页链接标记?

当使用 Facelets 作为视图技术(默认在 JSF 2.0 中使用)时,使用模板或复合组件应该相对简单。由于它基本上只是 XML,因此不需要 Java 代码。

4:是否可以将 *Faces(即 PrimeFaces、RichFaces 等)与 jquery 或 yui 等 javascript 库一起使用?这样做会产生任何冲突吗?

更重要的是,PrimeFaces 和 RichFaces 都内置了 jQuery (UI),PrimeFaces 还内置了 YUI。这也是他们获得奇特外观和/或特效的地方。对于与自己的jQuery脚本冲突,只需使用 jQuery.noConflict()< /a> 来抑制它。


当您准备好深入研究 JSF 2.0 时,我可以推荐以下教程:


更新根据评论:

但是,您能否详细说明为什么您个人偏好 Mojarra(参考实现)?

因为我是 Mojarra 的狂热用户。确实,这是主观的:)

客观地说,MyFaces 是 JSF RI 1.1 时期更好的选择。错误更少,性能更好。然而,自从新的 JSF RI 开发团队在 JSF RI 1.2 时代以来,进行了很多改进/修复。到目前为止,还没有任何技术原因让我们更喜欢其中一种。它是暴露和修复错误(维护/支持)的最高程度。

相关问题:

1: What are the differences between the reference implementation and MyFaces?

They are developed by different teams. Since both are supposed to adhere the JSF 2.0 spec, there ought to be no differences with regard to the base functionality as specified in JSF 2.0 spec. However, with regard to exposed and fixed bugs, there may be differences. My personal preference is Mojarra (the reference implementation).

2: Can jsf 2.0 with either reference implementation or MyFaces be deployed on any servlet container, i.e. tomcat/jetty, or must it be deployed only on a Java EE compliant container?

Yes. JSF 2.0 only requires a minimum of Servlet 2.5 API. So any Servlet 2.5 compatible container or even Java EE 5 applicationserver suffices. You may only need to disable the builtin JSF 1.2 API in a Java EE 5 applicationserver whenever you want to use JSF 2.0. Or, better, just use a Java EE 6 application server (Glassfish 3, JBoss AS 6, etc) since it already ships with JSF 2.0.

3: How difficult is it to create custom tags? For example a pagination link tag, similar to what is available in Grails?

When using Facelets as view technology (by default used in JSF 2.0), this should be relatively simple with a template or a composite component. Since it's basically just XML, no Java code is necessary.

4: Is it possible to use *Faces (i.e. PrimeFaces, RichFaces, etc) with a javascript library like jquery or yui? Are any conflicts created by doing so?

Even more, both PrimeFaces and RichFaces ships with jQuery (UI) builtin and PrimeFaces also YUI. That's also where they get their fancy look'n'feel and/or special effects from. As to conflicts with own jQuery scripts, just use jQuery.noConflict() to suppress it.


When you're ready to dive in JSF 2.0, I can recommend the following tutorials:


Update as per the comment:

However, could you elaborate on why your personal preference is Mojarra (the reference implementation)?

Because I am an avid user of Mojarra. True, it's subjective :)

Objectively said, MyFaces was the better choice during JSF RI 1.1 times. Less bugs and better performance. However, since the new JSF RI dev team during the JSF RI 1.2 times, a lot was improved/fixed. As of now there are no technical reasons to prefer the one over the other. It's at highest the degree of exposed and fixed bugs (maintenance/support).

Related questions:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文