HTML and CSS Reference
In-Depth Information
xmlns:ui=" http://java.sun.com/jsf/facelets "
xmlns:h=" http://java.sun.com/jsf/html "
xmlns:f=" http://java.sun.com/jsf/core " >
<ui:composition template="/WEB-INF/templates/simple.xhtml">
<ui:define name="title">
#{bundle['application.welcomepage.title']}
</ui:define>
<ui:define name="content">
#{bundle['application.welcome']}, #{user.name}! <br/>
<h:link value="#{bundle['application.welcomepage.return']}"
outcome="index"></h:link> <br/><br/>
</ui:define>
</ui:composition>
</html>
The welcome.xhtml page includes the simple.xhtml template page using the <ui:composition> tag. Like the
index.xhtml page, in the welcome.xhtml page, the "title" and the "content" of the template are overridden with the
page title and the page content. The page content displays a welcome message that includes the name property of the
User managed bean using the #{user.name} value expression. The page content includes a link to the introductory
page using the <h:link> tag. The <h:link> tag is a new tag that is introduced since JSF 2.0; it renders an HTML
anchor element. The value attribute of the <h:link> is rendered as the anchor text and its outcome attribute is used to
determine the target navigation page. In the welcome page, the outcome attribute value is set to "index" , which makes
an implicit navigation the "index.xhtml" page of the application.
Managed Beans
As illustrated in the Facelets pages section, there is a User managed bean that is binded with the input and output
components of the index and the welcome pages. Listing 1-8 shows the User managed bean.
Listing 1-8. The User Managed Bean
package com.jsfprohtml5.firstapplication.model;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class User implements Serializable {
private String name;
private String password;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
 
Search WWH ::




Custom Search