http://docs.oracle.com/javaee/5/tutorial/doc/bnaph.html
Facelets is a page declaration language that is used to build JavaServer Faces views using HTML style templates and to build component trees .
It includes:
Tag Library |
Prefix |
Example |
Contents |
---|---|---|---|
JavaServer Faces Facelets Tag Library |
ui: |
ui:component ui:insert |
Tags for templating |
JavaServer Faces HTML Tag Library |
h: |
h:head h:body h:outputText h:inputText |
JavaServer Faces component tags for allUIComponentobjects |
JavaServer Faces Core Tag Library |
f: |
f:actionListener f:attribute |
Tags for JavaServer Faces custom actions that are independent of any particular render kit |
JSTL Core Tag Library |
c: |
c:forEach c:catch |
JSTL 1.2 Core Tags |
JSTL Functions Tag Library |
fn: |
fn:toUpperCase fn:toLowerCase |
JSTL 1.2 Functions Tags |
Tag |
Function |
---|---|
ui:component |
Defines a component that is created and added to the component tree. |
ui:composition |
Defines a page composition that optionally uses a template. Content outside of this tag is ignored. |
ui:debug |
Defines a debug component that is created and added to the component tree. |
ui:decorate |
Similar to the composition tag but does not disregard content outside this tag. |
ui:define |
Defines content that is inserted into a page by a template. |
ui:fragment |
Similar to the component tag but does not disregard content outside this tag. |
ui:include |
Encapsulate and reuse content for multiple pages. |
ui:insert |
Inserts content into a template. |
ui:param |
Used to pass parameters to an included file. |
ui:repeat |
Used as an alternative for loop tags, such as c:forEach or h:dataTable. |
ui:remove |
Removes content from a page. |
<html xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
<head>
<title>Ejemplo</title>
</head>
<body>
<h:form>
<h:commandButton value="Login"/>
<commandLink value="hyperLink"/>
</h:form>
</body>
</html>
Tag |
Rendered As |
---|---|
commandButton |
|
commandLink |
|
For example a java.util.Date might be represented as a text string in the format mm/dd/yyyy or as a set of three text string.
<h:selectOneMenu value="#{country.localeCode}" onchange="submit()">
<f:valueChangeListener type="com.mkyong.CountryValueListener" />
<f:selectItems value="#{country.countryInMap}" />
</h:selectOneMenu>
public void processValueChange(ValueChangeEvent event) {
//do something
}
JavaServer Faces technology supports a mechanism for validating the local data of editable components (such as text fields).
This validation occurs before the corresponding model data is updated to match the local value. Like the conversion model, the validation model defines a set of standard classes for performing common data validation checks.
<h:inputText value="#{bean.property}">
<f:validateDoubleRange minimum="0" maximum="100"/>
<f:validateLength maximum="5" minimum="5"/>
<f:validator validatorId="validadorSemestre" />
</h:inputText>
Navigation is a set of rules for choosing the next page to be displayed after a button or hyperlink is clicked
<h:commandButton
action="#{bean.navigation}" value="Submit" />
<navigation-rule>
<from-view-id>/greeting.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/response.jsp</to-view-id>
</navigation-case>
</navigation-rule>
public String navigation(){
Usuario userAct = getUsuario();
executeLogicMethdo();
return"evxVerReporteT.xhtml";
}
Each of the component properties can be bound to one of the following:
Example
public class ExampleBB {
private Integer userNumber = null;
private InputText inputText;
public ExampleBB() {
super();
}
public void setUserNumber(Integer user_number) {
userNumber = user_number;
}
public Integer getUserNumber() {
return userNumber;
}
public String getResponse() {
doSomething();
return "response.xhtml";
}
}
<h:inputText value="#{exampleBean.userNumber}"/>
<h:inputText binding="#{exampleBean.inputText;}"/>
The most common functions that backing bean methods perform include the following:
To reference the backing bean from UI component tags, page authors use the unified expression language (EL) . Some of the features this language offers are.
<h:inputText id="userNo" value="#{UserNumberBean.userNumber}" validator="#{UserNumberBean.validate}" />
<inputText binding="#{UserNumberBean.userNoComponent}" />
http://docs.oracle.com/javaee/5/tutorial/doc/bnaqq.html