views:

280

answers:

2

Even though i spend whole days developing a JSF application, i've never had any training on the matter and I have to admin I am a still confused how the whole JSF puzzle fits together. JSF just looks a bit thrown together to me.

  • jsf-api
  • jslt
  • facelets
  • myfaces
  • trinidad
  • tobago
  • jsp api

I'd be very grateful if anyone could give me a quick description of these components, which ones are standard, which ones can be left out, which ones can/need to be used together

+2  A: 
  • jsf-api are the interfaces and classes in javax.faces
  • jstl is a standard set of tags (used primarily in JSP) - most of them are replaced with JSF-tags, btw
  • facelets is a presentation and templating framework (like jsp)
  • myfaces is an implementation of the JSF standard. The other possibility if JSF RI (reference implementation)
  • trinidad and tobago are component libraries - some goodies that aren't included in the default set of jsf components
  • jsp is the alternative to facelets (or vice versa), which is as well a presentation framework.
  • UEL - (you didn't ask, but it's important) - Unified Expression Language - the set of rules for your #{..} expressions
Bozho
+3  A: 

JSP and JSTL

JSP has undergone many iterations, but this is the core JEE dynamic page technology. This is a servicable API, but working with JSPs often means more manual management of code/resources.

JSTL is the JSP Standard Template Library. This is a set of standard JSP tags. Do not mix these tags with JSF tags; they belong to a different programming model.

JSF API

The JSF specification. This is the core of the JSF Model-View-Presenter framework. This specifies a simple set of core components and the core lifecycle artefacts. There are two widely known implementations: Mojarra (the open sourced Sun API) and Apache MyFaces. Part of JEE5 and above.

Facelets

A view technology designed for JSF. Use this instead of JSPs. You cannot use JSP tags in Facelets views. This is not standard in JEE5, but is standardised in JSF2 (and therefore the upcoming JEE6). The better templating provided by Facelets often means you can rely less on 3rd party libraries.

Facelets provides some tags that look like JSP JSTL tags, but don't share any code. These tags should generally be avoided too (see Facelets doc for advice).

Apache Trinidad and Tobago

These are JSF libraries that provide components and other facilities. Because the core set of controls is rather basic, it is common to use such libraries, especially if Facelets is not used. These are not part of the JEE standard. Library compatibility varies. See also jsfmatrix.net.

McDowell
I agree the disrecommendation to mix JSF with JSTL, but that usually only concerns the JSTL core and format taglibs for which there's indeed already a JSF replacement. The JSTL functions taglib however is extremely useful and still do so in JSF. The JSTL sql and xml taglibs are irrelevant and not worth using in real world. The core problem of mixing JSF with JSTL is that they doesn't run "in sync" as you'd expect from coding. See it as JSTL running first from top to bottom and then handing over the entire result to JSF for further processing. Problematic indeed!
BalusC
I don't advocate a blanket ban on JSTL tags - folk should read the documentation and judge for themselves. It is an area where people run into problems, particularly when they bring their JSP expectations into JSF apps and treat it as just another tag library. Intermingling JSF and non-JSF tags requires a detailed understanding of both lifecycles (and often feels to me too much like programming to the implementation and not the abstraction). You are right about the functions, though. New apps should try to use Facelets - it is a better fit.
McDowell
Isn't JSTL the JSP Standard Tag Library?
InverseFalcon
@InverseFalcon - it is, but I'm not sure what your point is.
McDowell