Wednesday Jan 22, 2014

JSF 2.2 View Actions

View parameters and pre-render view event listeners were two of the key features added in the JSF 2.0/2.1/Java EE 6 time frame to improve bookmarkability and HTTP GET support. However, the problem with the pre-render view event is that it is triggered both when the view initially loads as well as on all subsequent JSF post backs. This makes it harder to use for the common pattern of looking at passed-in page parameters (usually in the URL query string) and doing some page initialization only once. You could get around this by putting in an explicit post back check in your listener, which is often hard to miss and somewhat hard to understand. As a result, the Seam 3 Faces module added a more focused and powerful view action component.

The good news is that JSF 2.2 standardizes the popular Seam 3 view action feature all but as-is. Hantsy Bai explains the very useful new feature well, including a good bit of technical detail.