Tuesday, February 26, 2008

JSF strange behaviors

Two strange behavior of JSF (at least this is what I remembered)
1. Your backing bean only specify getter method (in my case, it returns a collection) and you're using it in h:dataTable. Submitting the form (invoking any action on the page) does nothing, no exception, no sign of anything happening... not a single clue. After one hour wasted, I found out that creating a setter method solves it. It seems that JSF try to call the setter and then fails ungracefully.

2. I have a selectOneMenu and I use a getter method for the selectItems, the List of SelectItem are created whenever the getter is invoked (I know it's not good, just hear the story :). Accessing the page yields exception complaining that there is no selectItem provided (null). Strange thing is the getter method is invoked not in render phase, why? Long story short, I add a property in the backing bean holding the List of selectItem and the getter method is still the same getter method as previously, only at this time I initialize the collection once (better pattern, rite? ;). It works! No more error.


These two strange behaviors that I remembered, are they somehow in the JSF specification?
... I guess I have to try to find out myself.

No comments: