Facelets uses the jsfc attribute to convert HTML elements to their associated JSF components. This is rather helpful for fast prototyping as it allows you to create your views using a visual design tool. However I recently discovered this blog post by Cay Horstmann where he lays waste to the use of jsfc together with complex components such as h:dataTable.
This alarmed me as Cay Horstmann is the author of multiple of my favorite Java books. However my Google-fu skills have yielded zero results when trying to determine the scope/nature of the problem, other than a recent post by Ed Burns, who seams to like jsfc (and he is after all the co-spec lead for JSF). So my question is simply, is it recommended to use jsfc with Facelets ? and if not what’s the problem it introduces.
As you said, the
jsfcattribute is essentially usefull when you have to “convert” an HTML prototype to a JSF page. For example, when you have an HTML input text:you can add the
jsfcattribute in order to convert this HTML component into a JSF component:This is equivalent to writing the following JSF code:
As stated in the Facelets documentation here or here, the attribute
jsfccan also be used to “map” Facelets components. For example, you can remove a part of the HTML code:You can also create a table using this attribute:
In this example, we do not link this table to a
h:datatablecomponent, but we create a table with HTML code, using the JSF componentui:repeatto iterate on rows.As you can see, the
jsfcattribute can be used to convert one HTML component into one JSF component in a JSF page. So for complex components, such as the datatable, you will have to use some workarounds (usingui:repeatinstead of theh:datatablecomponent).Another point is that you will not be able to use third-libraries components such as the ones proposed by RichFaces, IceFaces, Tomahawk, and so on. And these libraries are really one of the interests of JSF.
So to summarize:
jsfccan be usefull to transform a HTML prototype into a JSF applications, essentially for creating Proof of Concepts or designing the general UI. However, I think it is better to avoid this component once the “real” development starts…