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

Editing/updating a table row


One of the most convenient approaches for editing/updating a table row consists of using a special property to track the row edit status. This property can be named edited and it should be of the type boolean (default false). Define it in the POJO class, as shown in the following code:

public class Players {
  ...
  private boolean edited;
  ...
  public boolean isEdited() {
    return edited;
  }

  public void setEdited(boolean edited) {
    this.edited = edited;
  }        
}

Note

If your POJO class is an entity class, then define this new property as transient, using the @Transient annotation or transient modifier. This annotation will tell JPA that this property doesn't participate in persistence and that its values are never stored in the database.

Next, assign an Edit link to each row. Using the rendered attribute, you can easily show/hide the link using a simple EL condition; initially, the link is visible for each row. For example, take a look at the following...