3

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?

JacJ122
  • 53
  • 1
  • 4

1 Answers1

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:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks for the insightful answers; they were precisely what I was looking for. However, could you elaborate on why your personal preference is _Mojarra_ (the reference implementation)? Thanks. – JacJ122 Feb 02 '11 at 14:59
  • Thanks for explaining your preference for _Mojarra_. Based on your answers and links, I now feel comfortable delving into JSF 2.0 using _Mojarra_. However, I do have one last question: aside from using [PrettyFaces](http://ocpsoft.com/prettyfaces/), are there any other ways to achieve restful/clean urls (all types of requests, or at the very least POST & GET) in JSF 2.0? – JacJ122 Feb 02 '11 at 16:09
  • There are basically no 3rd party alternatives to PrettyFaces. At least, none comes to mind. You could however homegrow it yourself with help of a `Filter` or `PhaseListener`. But that requires in depth knowledge of both Servlet and JSF API's. PrettyFaces is perfectly fine. – BalusC Feb 02 '11 at 16:24
  • While RichFaces does ship with jQuery, jQuery is not always included in the page. If I include my own jQuery, it will work when RichFaces doesn't include its jQuery, but will break/conflict if I use a RichFaces component that trigger jQuery inclusion. – Hendy Irawan Jan 27 '12 at 13:47
  • @Hendy: in JSF2 you can use `` to include RichFaces' own jQuery. It won't be included twice if a RichFaces component in turn also needs to include it. The same story applies to PrimeFaces and other JSF2 component libraries. – BalusC Jan 27 '12 at 13:50