What is the difference between JSF and Facelets?

♀尐吖头ヾ 提交于 2019-12-03 06:42:36

问题


I am following the Java EE6 tutorials and I don't understand the difference between JSF and Facelets. Chapter 4 goes has a section 'Developing a Simple JavaServerFaces Application' and Chapter 5 has a section 'Developing a simple Facelets' application and as far as I can see both these examples use the exact same process - an .xhmtl page for the markup, a backing bean to hold some data and then a web.xml file that maps urls to the 'FaceletsServlet'.

From what I can gather Facelets are .xhtml pages with tags such as <h:head> and <h:inputText> used to mark up the webpages.

But then what is JSF? I have read that either JSP or Facelets can be used with JSF so does that mean the role of JSF is to provide the tag libraries that are used by JSP or Facelets?


回答1:


  • JSF - Java Server Faces is the overarching application development framework. It contains many aspects, one of which is the view handler. JSF (Wikipedia), JSF (Stack Overflow).

  • Facelets is a view handler for JSF. Before JSF 2.0, JSP was the default view handler, but the problem was JSP didn't work very well with JSF's component based framework. Facelets was designed from the ground up to work well with JSF. Facelets (Wikipedia), Facelets (Stack Overflow)

Tag libraries are a different part of the JSF spec. They are collections of UI components. Facelets is not a taglib, and many tag libs can be used with Facelets.




回答2:


JSF is as you probably already gathered a component based system. These components are organized in libraries.

JSF is the base standard and defines the standard taglibs core and html. These include the tags for such basic elements as input fields, buttons, labels and links. Facelets is the facelets taglib, it was originally distributed seperatly but now it is included in the JSF standard. Facelets contains tags like ui:composition, ui:insert and ui:define that can be used for templating. There are many other tag libraries that can be used with JSF like primefaces, richfaces, tomahawk and trinidad.




回答3:


JSF is used with Facelets, before we were using jsp. Facelet is a view technology based on xml.

Facelets was originally created as a separate, alternative view declaration language for JSF 1.1 and JSF 1.2 which both used JSP as the default view declaration language. Starting from JSF 2.0, Facelets has been promoted by the JSF expert group to be the default view declaration language. JSP has been deprecated.

Important features facelets provides are templating, composite components, content reuse.

http://www.ibm.com/developerworks/library/j-facelets/



来源:https://stackoverflow.com/questions/11457765/what-is-the-difference-between-jsf-and-facelets

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!