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

Facelets pitfalls


It is a well-known fact that JSF pitfalls are not easy to understand and fix. This is mostly because their roots originate in: JSF life cycle, bad practices of using listeners and events, misunderstandings regarding EL processing and evaluation, conflicting combinations of tag handlers with components, and so on.

In this section, we will focus on three common Facelets pitfalls.

AJAX and <ui:repeat>

There is a common scenario to use AJAX for re-rendering the content of an <ui:repeat> tag. It is absolutely intuitive to write something like the following code:

<h:form>
  <ui:repeat id="playersId" value="#{playersBean.dataArrayList}" var="t">
    <h:outputText value="#{t.player}" />
  </ui:repeat>            
  <h:commandButton value="Half It" action="#{playersBean.halfAction()}">
    <f:ajax execute="@form" render="playersId" />
  </h:commandButton>
</h:form> 

So, initially, there is a list of n players and when we click...