Insights into Java Server Faces

2013/01/15

Howto use PreRenderViewEvent on a component or any managed bean

Filed under: JSF — Hanspeter @ 23:15

JSF 2.0 introduced many events, one of it is javax.faces.event.PreRenderViewEvent. But there is a pitfall – listeners for this event are registered in application scope. Therfore one must be very carefull to not subscribe any UIComponent or managed bean as listener for PreRenderViewEvent. However, sometimes it’s required to do something during PreRenderViewEvent processing on a UIComponent – for example modify the completely built component tree e.g. using some rules.

(more…)

2013/01/14

Suppress second execution of buildView() as performane improvement when using Facelets views

Filed under: JSF — Hanspeter @ 21:58

Since JSF 2.0 when using Facelets view definitions the component tree is built twice on postback requests, once in RESTORE_VIEW phase and once in RENDER_RESPONSE phase. The rebuild in the render phase is necessary in case the page author used conditional includes. On big views several hundred component build the component tree – this may take some 100ms per buildView() execution – saving that once will improve the performance. (more…)

Blog at WordPress.com.