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()}"> ...

Get Mastering JavaServer Faces 2.2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.