Facelet insert Tag

This tag is used to replace the content defined in another facelet to the template. This tag takes one attribute that is not a required attribute and is used in conjunction with define tag. If you set this attribute same as defined in define tag then that content within define tag will be included. If it doesn't match then the content specified within opening and closing tag of this insert tag will be displayed. For example, in the code below in "insert.xhtml" there is not any define tag whose name attribute value is "face5" and this value is used in the second file "inserttemplate.xhtml". So the content ("This is the default text rendered") specified within opening and closing tag of insert tag is displayed. While there is one insert tag whose value of name attribute ("face1") matches with that of define tag, so the content "RoseIndia Facelet Tags Tutorial" and "Welcome to the Facelet world.........." will be replaced to the insert tag.

insert.xhtml :



xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">

Content above composition tag will not be rendered.


RoseIndia Facelet Tags Tutorial


Welcome to the Facelet world..........



Enter UserID :





Enter Password :









Content below composition tag will not be rendered.

inserttemplate.xhtml :



xmlns:ui="http://java.sun.com/jsf/facelets">

facelet example







face5">

This is the default text rendered



Rendered Output :

Html Source Code :





facelet example



RoseIndia Facelet Tags Tutorial


Welcome to the Facelet world..........


Enter UserID :



Enter Password :
value="" />



This is the default text rendered



This tag contains only one attribute :

name : This attribute is used to give the name of the content to be included in template. This value of name attribute must be same as name attribute in define tag. If name value specified here doesn't match with any name attribute specified in define tag then the content specified within opening and closing tag of this insert tag will be displayed. This has been explained in the above example.

0 comments:

Post a Comment