Facelet Introduction: Facelet is for the JSF component model tailor-made template language, the white page is the template, we can first of all the frame of the page to build up the dynamic part we can directly to reference. This will reduce the number of duplicate code written. While this means that the facelet itself has a high degree of integration with the JSF lifecycle, using Facelets, the resulting template builds the component tree, not the servlet. This allows for better reuse because components can be combined into another component.
II Facelet Usage: First, the insertion of tag library
Template page: On the template page, we use the <ui:insert/> tag, we can directly use <ui:include/> reference page in the label, also can be vacant. Take a look at the following example:
<f:view locale= "ZH_CN" > <f:loadbundle basename= "Messages" var= "msgs"/> Dynamic page: When the template page is generated, we can dynamically generate each page. First we need to use the <ui:composition template= "template.xhtml"/> tag to introduce the template page above. The content of the page is then dynamically defined with the <ui:define/> tag. Examples are as follows:
Page styles and scripts: the introduction of styles and scripts is typically placed inside the Iii. the question of JSF internationalization
You must first define a national configuration file with a name format of xxx_language.properties, such as Message_en.properties,message_zh_ Cn.properties, then we need to introduce on the template page, you can refer to the top of the template.xhtml page
<f:loadbundle basename= "Messages" var= "Msgs"/>
When we need to initialize local locals, we simply add the following phrase
<f:view locale= "ZH_CN" >
In specific use, only need to call the definition of the language on it, the following gives a complete example
And the internationalization of the file definition is very simple, such as the first is an en language
Login.logo = Login
login.username = User Name
login.userpasswd = Password
Login.userpermiss = Permission
login.administrator = Administrator
login.operator = operator
login.viewer = Viewer
Login.submit = Submit
login.cancel = Cancel
Then it's ZH_CN language.
Login.logo = Login
login.username = user
login.userpasswd = password
login.userpermiss = permission
login.administrator = Administrator
login.operator = operator
login.viewer = Monitor
login.submit = OK
login.cancel = Cancel
This is a bit of experience with JSF.