JSF 2 InputText Example

 

In this example, we will see how to add an input text in a JSF page using the <h:inputText ../>  tag.

 

1. Project structure

JSF2-InputText-Example

 

2. JSF pages

We will add an inputText and link it to the name attribute of user bean.

File : index.xhtml

The <h:inputText ..> will render an HTML input element of type text.

In the welcome page, we will display the inputText value submitted from the index page.

File : welcome.xhtml

 

3. Managed bean

User

 

4. Test It

We enter a name in the inputText and press the button.

JSF2-InputText-Example-1

 

JSF2-InputText-Example-2

 

Download source code