jsp vs facelets
Post on 28-Nov-2014
Embed Size (px)
Faceletsa atay ivici Apache MyFaces PMC email@example.com
a atay iviciApache MyFaces Project PMC Member OpenLogic Expert Group Member Sourceforge jsf-comp project developer JSF Client Side Validators Acegi Security Frameworks JSF Components JFreeChart for JSF : JSF Chart Creator FacesTrace: Visual Debugger of JSF
AgendaJSF and JSP Facelets Jsfc and inline texts Templating Composition Components EL Functions JSTL Support Custom Logic Tags
JSF and JSPJSP is the default view technology JSP tags refer to JSF components h:commandButton = HtmlCommandButtonMixing them brings overhead because of two different lifecycles
JSF and JSP (Advantages)JSP is well adopted, reduces learning curve of JSF. Above is the only advantage
JSF and JSP (Disadvantages)JSP is created to generate dynamic output not to create component trees Two different lifecycles (overhead) Content Interweaving Issues
JSF and JSPJSF 1.1 - Initial request (e.g. index.jsf)1. 2. 3. 4. 5. 6. FacesServlet gets the request and JSF lifecycle begins restoreState returns null and a new view is created (createView) with view id = index.jsp (jsp is the default suffix) lifecycle jumps to renderResponse renderView is called that dispatches index.jsp to the container Container traverses all the tags, tags call components encode methods during component tree is created State is saved via writeState and buffered output is rendered to the client.
JSF 1.2 - a servletwrapper is used instead of f:view to buffer the content and component tree is created before rendering
FaceletsA viewhandler purely created for JSF No more JSP .xhtml instead of .jsp No tld files and no tag classes to defined a UIComponent Faster than using JSP&JSF
Migrating from JSP to Facelets
InstallationAdd jsf-facelets.jar to the classpath Add viewhandler config to faces-config.xml Change javax.faces.DEFAULT_SUFFIX to .xhtml
*.taglib.xmlConcept similar to tld but lightweight Used to define components, converters, validators, composition components, custom logic tags, functions and etc.
JsfcJsfc : jwcid concepty in Tapestry