Presentation is loading. Please wait.

Presentation is loading. Please wait.

Facelets BY: Tejashri Udavant..

Similar presentations


Presentation on theme: "Facelets BY: Tejashri Udavant.."— Presentation transcript:

1 Facelets BY: Tejashri Udavant.

2 Facelets A 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

3 Migrating from JSP to Facelets
taglib uri=" prefix="h"%> taglib uri=" prefix="f"%> <html xmlns=" xmlns:h=" xmlns:f="

4 Installation Add jsf-facelets.jar to the classpath
Add viewhandler config to faces-config.xml Change javax.faces.DEFAULT_SUFFIX to .xhtml

5 *.taglib.xml Concept similar to tld but lightweight
Used to define components, converters, validators, composition components, custom logic tags, functions and etc.

6 Jsfc Jsfc : jwcid concepty in Tapestry
<h:commandButton id=“btn_save” value=“Save” action=“#{bean.method}” /> <input jsfc="h:commandButton" type="submit" id=“btn_save" value=“Save“ action=“#{bean.method}”/> Provides integration with HTML editors

7 Inline Texts Inline Text: Display texts without a UIComponent
<h:outputText value=“#{IndexPageBean.welcomeMessage}” /> <h1>#{IndexPageBean.welcomeMessage}</h1>

8 Support for Unified EL Facelets support the Unified EL
#{BeanName.field} same as; ${BeanName.field}

9 Templating A template is an xhtml with placeholders
Placeholders are marked with ui:insert Fragment from Template.xhtml <title> <ui:insert name="title">Default Title</ui:insert> </title> In order to use the template ui:composition is needed. Fragment from index.xhtml <ui:composition template="/template.xhtml"> <ui:define name="title"> Welcome to index page </ui:define>

10 Composition Components
Composition component is basically a template userInfo.xhtml <ui:composition xmlns:ui=" <h3>Logged as : #{user}</h3> </ui:composition> myfacelets.taglib.xml <tag> <tag-name>userInfo</tag-name> <source>tags/userInfo.xhtml</source> </tag> Use as; <ds:userInfo user="#{myBean.currentUser}"/>

11 EL Functions MyFunctions.java myfacelets.taglib.xml Use as;
public static String length(String name) { if( name == null ) return null; else return String.valueOf( name.length() ); } myfacelets.taglib.xml <function> <function-name>length</function-name> <function-class>faceletsbox.utils.CustomerUtils</function-class> <function-signature> java.lang.String length(java.lang.String) </function-signature> </function> Use as; #{ds:length(MyBean.userName)}

12 JSTL Support With JSP, mixing JSF and JSTL is problematic
Facelets brings limited but faultless support <c:if> <c:forEach> <c:catch> <c:set>

13 Custom logic tags JSTL like logic tags by extending Facelets TagHandler myfacelets.taglib.xml <tag> <tag-name>if</tag-name> <handler-class>mycompany.myproject.utils.IfHandler</handler-class> </tag> Use as; <ds:if test="#{MyBean.isLoggedIn}"> Welcome </ds:if>

14 List of built-in Facelets tags
<ui:component/> <ui:composition/>  <ui:debug/>  <ui:decorate/> <ui:define/> <ui:fragment/> <ui:include/> <ui:insert/> <ui:param/> <ui:remove/> <ui:repeat/>


Download ppt "Facelets BY: Tejashri Udavant.."

Similar presentations


Ads by Google