Saturday, 26 March 2016

JSF-3

JSF - Facelets Tags

Facelets JSF Tags

JSF provides special tags to create common layout for a web application called facelets tags. These tags gives flexibility to manage common parts of a multiple pages at one place.
For these tags you need to use the following namespaces of URI in html node.
<html 
   xmlns="http://www.w3.org/1999/xhtml" 
   xmlns:ui="http://java.sun.com/jsf/facelets" 
>
Following are important Facelets Tags in JSF 2.0:
S.N.Tag & Description
1Templates
We'll demonstrate how to use templates using following tags
  • <ui:insert>
  • <ui:define>
  • <ui:include>
  • <ui:composition>
2Parameters
We'll demonstrate how to pass parameters to a template file using following tag
  • <ui:param>
3Custom
We'll demonstrate how to create custom tags.
4Remove
We'll demonstrate capability to remove JSF code from generated HTML page.

JSF - Convertor Tags

JSF Convertor Tags

JSF provides inbuilt convertors to convert its UI component's data to object used in a managed bean and vice versa.For example, these tags can convert a text into date object and can validate the format of input as well.
For these tags you need to use the following namespaces of URI in html node.
<html 
   xmlns="http://www.w3.org/1999/xhtml" 
   xmlns:f="http://java.sun.com/jsf/core"  
>
Following are important Convertor Tags in JSF 2.0:

S.N.Tag & Description
1f:convertNumber
Converts a String into a Number of desired format
2f:convertDateTime
Converts a String into a Date of desired format

Custom Convertor
Creating a custom convertor

JSF Validator Tags

JSF provides inbuilt validators to validate its UI components. These tags can validates length of field, type of input which can be a custom object.
For these tags you need to use the following namespaces of URI in html node.
<html 
   xmlns="http://www.w3.org/1999/xhtml" 
   xmlns:f="http://java.sun.com/jsf/core"  
>
Following are important Validator Tags in JSF 2.0:
S.N.Tag & Description
1f:validateLength
Validates length of a string
2f:validateLongRange
Validates range of numeric value
3f:validateDoubleRange
Validates range of float value
4f:validateRegex
Validate JSF component with a given regular expression.
5Custom Validator
Creating a custom validator

JSF DataTable

JSF provides a rich control named DataTable to render and format html tables.
  • DataTable can iterate over collection or array of values to display data.
  • DataTable provides attributes to modify its data in easy way.

HTML Header

<html 
   xmlns="http://www.w3.org/1999/xhtml"   
   xmlns:h="http://java.sun.com/jsf/html">
</html>
Following are important DataTable operations in JSF 2.0:
S.N.Tag & Description
1Display DataTable
How to display a datatable
2Add data
How to add a new row in a datatable
3Edit data
How to edit a row in a datatable
4Delete data
How to delete a row in datatable
5Using DataModel
Use DataModel to display row numbers in a datatable

 

1 comment: