Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Are JSF 2.0 Facelets really XHTML-conform?

 
Kai Wähner
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

As I have read so far, a huge improvement of JSF 2.0 towards 1.2 is the usage of Facelets instead of JSPs, which are XHTML-conform and so could be designed with HTML-Tools, right?

This is why many developers prefer Wicket or Tapestry, where the development of the view is possible with HTML-Tags and no taglibs or other code.

But in a JSF 2.0 Hello World example you can see this:





The JavaBean is accessed via #{helloWorldBean.now}. That is not XHTML-conform, isn't it?

So maybe I do not understand it correctly - JSF 2.0 is still not pure HTML such as e.g. Wicket tags (e.g. <form wicket:id="form" /> )?

Thanks for explanations...
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, technically, I wouldn't really call them XHTML. In fact, JSF in general has not done well with any variant of HTML in its views.

JSF and Facelets are not precisely the same thing, although Facelets does become part of basic JSF in JSF2. I don't remember the precise allowable formats, but the one I've always used is an XML format, and yes, I put the filename ".xhtml" on them, but that's a notational convenience.

A "pure" JSF/Facelets view would ideally not have any actual HTML in it at all, so as to make it possible to use the same view source with different renderers such as one for WAP. That's what I generally try to do these days, although I must admit when you need row/column spanning capabilities in core JSF, the work-arounds are really annoying.
 
Rainer Eschen
author
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you found this example? It should be



or in a more Facelets writing


 
Kai Wähner
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you found this example?


Sorry, I do not remember anymore...

But besides this syntax error, any other opinions to my question besides Tim?

A colleague told me: Yes, it still is pure XHTML syntax - but of course, a pure (X)HTML editor cannot show any value for the bean.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kai Waehner wrote:
Where do you found this example?


Sorry, I do not remember anymore...

But besides this syntax error, any other opinions to my question besides Tim?

A colleague told me: Yes, it still is pure XHTML syntax - but of course, a pure (X)HTML editor cannot show any value for the bean.


Actually, even in Facelets, it's often better to use the outputText control. For one thing, the container components such as panelGrid can be a little touchy about recognizing free-form text as discrete child elements. For another, you don't get the side benefits like styling options that are available from the outputText tag, so you'd have to use a div or span. Finally, if you have any intent of ever rendering the form to a different media (like PDF) or destination (small-screen device such as a cellphone), using raw HTML can at best reduce portability and at worst end up as part of the displayed text in the output.
 
Rainer Eschen
author
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is: is it really important ta have a conform syntax? The most of us use an IDE-based editor that supports JSF natively or can handle XML. So, HTML editors are used (in theory) by web designers who prepare the presentation of a page and the developer is doing the rest (add EL stuff). But, reality shows that developers play both roles in a lot of cases.

Sure, Facelets are described to support editing in a standard HTML editor. But, the most important part are the possibilities that Facelets deliver to get reuse:

* Templating
* Tags to define

 
Kai Wähner
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, HTML editors are used (in theory) by web designers who prepare the presentation of a page and the developer is doing the rest (add EL stuff). But, reality shows that developers play both roles in a lot of cases.


I agree with you 100 percent! The question came up because I am doing an evaluation of different web frameworks at the moment, and some guys think this is an important advantage - in huge projects, with some designers :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic