JSF 2.0 Tag Library

JSF 2.0 Tag Library


Posted in : Java Posted on : May 29, 2012 at 7:51 PM Comments : [ 0 ]

In this tutorial you will learn about the the tag libraries used in JSF.

JSF 2.0 Tag Library

In this tutorial you will learn about the the tag libraries used in JSF.

To develop an JSF application in an convenient way Sun Microsystems, Inc provided some tag libraries that fulfils the basic requirement or functionality to the discrete JSF applications. To develop JSF applications not only its own tag libraries core and html but, also JSTL core1.2  and JSTL functions1.1 tag libraries are supported. Tag libraries of JSF core and html expresses the JavaServer Faces interface on the inside view template, these can be used with JSP or Facelets or both.

Each JSF Tag Libraries have their own namespace, or prefix these are as follows :

  • JSF Core : JSF core library.
  • JSF Html : JSF html library.
  • JSF Composite : JSF composite library.
  • JSF ui : JSF facelets library.
  • JSTL Core : JSTL core library.
  • JSTL Functions : JSTL functions library.

To include above these tag libraries you will have to use taglib directive (<%@ taglib uri="" prefix="" %>) on the JSP page.

Following table describes the libraries and their corresponding uri and prefix.

Library URI Prefix
JSF core http://java.sun.com/jsf/core f
JSF html http://java.sun.com/jsf/html h
JSF composite http://java.sun.com/jsf/composite composite
JSF ui http://java.sun.com/jsf/facelets ui
JSTL core http://java.sun.com/jsp/jstl/core c
JSTL functions http://java.sun.com/jsp/jstl/functions fn

NOTE : You would be required the jsf-impl.jar, jstl.jar, standard.jar files to use these above libraries.

You can download jar files from here or http://javaserverfaces.java.net/download.html and from http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html.

Some of the tag examples of each library are as follows :

JSF core tags (Click here for JSF core tag library tutorial)

1. <f:attribute></f:attribute> tag is used to add attribute to the UIComponent.

2. <f:actionListener></f:actionListener> tag is used for registering ActionListener instance on the UIComponent.

JSF html tags (Click here for JSF html tag library tutorial)

1. <h:commandButton></h:commandButton> tag is used for rendering the html input element.

2. <h:commandLink></h:commandLink> tag is used for rendering the html anchor element <a>.

JSF composite tags (Click here for JSF composite tag library tutorial)

1. <composite:interface></composite:interface> tag declares composite component's usage contract.

2. <composite:implementaion></composite:implementation> tag is used for defining the composite component's implementation.

JSF ui tags (Click here for JSF ui tag library tutorial)

1. <ui:component></ui:component> tag is used for creating a component.

2. <ui:define></ui:define> tag is used to define content.

JSTL core (Click here for JSTL core tag library tutorial)

1. <c:forEach></c:forEach> tag is used for iterating functionality.

2. <c:if></c:if> tag is used for evaluating the conditional statement when if is 'true' etc.

JSTL functions (Click here for JSTL functions tag library tutorial)

1. { fn:toUpperCase() }tag is used to change a string written in lower case to upper case.

2. { fn:contains() } tag is used to test whether the string that is inputted is contained a substring or not. etc.

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics