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.
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…)
It’s quite a while since my last post and this one is related to JSF but not only, it might also be usefull for other use cases. I will show a way to not allocate any space for empty collections (mainly Lists/Maps) unless a first entry is added – and that in a way that is fully transparent for the using part of the Map/List. This helps to keep managed beans containing data as small as possible and therefore allows to reduce session size. (more…)
Imagine a JSF 2.0 based input view working with AJAX and you have h:messages positioned above of this input form – and you want the messages area to be rerendered on each validation step. You now will have to add the clientId of h:messages to all f:ajax render=”..” behavior definitions – or somehow add the clientId of h:messages automatically to the list of components to be rendered on partial requests. This article will show how to implement the automatic adding of a clientId to the list of components to render on partial view requests. (more…)
Sometimes binding of UIComponent comes in very handy. For example if you want to pass client ids into a composite component to alow the cc to use these ids with attributes. It would be very boring to specify the full client ids explicitly. This article will show how component references can be passed on in a simple generic way.
According to this Oracle whitepaper it is not possible to use Tomahawk File Upload within a JSF Portlet – they recommend to use a non JSF Portlet for that. Well, we found a solution to get File Upload working within JSF Portlets. (more…)
Sometimes it would be nice to combine multiple properties files into one single ResourceBundle. For example, a part of the resources is provided by some library and another part of the resources should be provided by the application using that library.
JSF provides validation, you can even attach multiple validators to a single input component. But it does not (yet?) support validation across multiple input components. To address this shortcoming we developed a MultiValidator component. (more…)
Beside his appointments at Jazoon 2009 we had the opportunity to have Ed Burns at our office in Credit Suisse (CS) to work on some suggenstions regarding JSF improvements. After a short discussion it was agreed that there is only one point to look at on the currently used JSF 1.2 and Facelets – the other improvements will most likely be covered by JSF 2.0 or would have to be looked into later. (more…)
Real application need to handle unexpected Exceptions in a save way by e.g. render an error page and behave according to the type of exception (some exceptions might allow to show a message and continue with the application, other might need to terminate the session). JSF 2.0 will provide exception handling support, but you can also handle exceptions before JSF 2.0 using a custom lifecycle as shown below.