Book Image

Mastering JavaServer Faces 2.2

By : Anghel Leonard
Book Image

Mastering JavaServer Faces 2.2

By: Anghel Leonard

Overview of this book

Table of Contents (20 chapters)
Mastering JavaServer Faces 2.2
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The JSF Life Cycle
Index

Adding a new row


Adding a new row is also a simple task. First, you need to provide a form that reflects a table row content, as shown in the following screenshot:

This form can be easily implemented using the following code:

...
<h:inputText value="#{playersBean.player}"/>
<h:inputText value="#{playersBean.age}"/>
<h:inputText value="#{playersBean.birthplace}"/>
<h:inputText value="#{playersBean.residence}"/>
<h:inputText value="#{playersBean.height}"/>
<h:inputText value="#{playersBean.weight}"/>
<h:inputText value="#{playersBean.coach}"/>
<h:inputText value="#{playersBean.born}">
  <f:convertDateTime pattern="dd.MM.yyyy" />
</h:inputText>
<h:inputText value="#{playersBean.ranking}"/>
<h:commandButton value="Add Player" action="#{playersBean.addNewPlayer()}"/>
...

The button labeled Add Player will call a managed bean method that creates a new Players instance and adds it in the collection that feeds the table, as shown...