wood burning stoves 2.0*
The moose likes JSF and the fly likes JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF "Update Model Values" phase exception" Watch "JSF "Update Model Values" phase exception" New topic
Author

JSF "Update Model Values" phase exception

Hernán Quevedo
Ranch Hand

Joined: Mar 18, 2009
Posts: 31
Hey.

I just debugged my app with a phaseListener, logging in server console before and after each phase is done; I came to realize that the fifth phase was skipped, so, the fourth one is having trouble updating the bean's attributes and no exception is logged in console but in page, which is a NullPointer one.

Any ideas on how to capture the exact LOC where the phase is snapping?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Read the NPE trace and fix the code accordingly.
Hernán Quevedo
Ranch Hand

Joined: Mar 18, 2009
Posts: 31
Thanks, Bauke, but the thing is that there absolutely no trace whatsoever, non on the server console nor the page; the only thing that displays on the page is the message java.lang.NullPointerException, period. That's why is so frustating.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Are the setters of the bean doing more than only setting values?
Hernán Quevedo
Ranch Hand

Joined: Mar 18, 2009
Posts: 31
They were doing a validation in the form of if(parameter != null && parameter.something) then set

I removed all those validations and still this misterious problem appears... Maybe some default constructor thing? That default contructor only sets the properties in null

thanks a lot..
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
The bean is already constructed during restore view phase.

Well, if the setters doesn't do more than only setting properties, I don't know it either.

Just run a debugger.
Hernán Quevedo
Ranch Hand

Joined: Mar 18, 2009
Posts: 31
Well, it's finally solved.

The problem was this:

h:selectOneRadio id="xxx" value="#{item.checked}" onclick="validateOption(this)">
<f:selectItem itemValue="#{item.id}">
</h:selectOneRadio>

where item.checked is a boolean property so I can know which item in the list is selected, and item.id is a unique key to make the onclick function work and validate that only one of those radios is selected at a time.
For some reason I will never know, those lines make the lifecycle throw nullpointer o validation errors during the fourth phase and skip to the sixth.
Maybe I'm using it wrong although I did exactly the same on several pages before without a single problem.

The solution was to use the ibm JSF extended tag

<hx:inputRowSelect selectOne="true" value="#{item.checked}"/>

Again, Sun should emphasize on making JSF a more friendly and elocuent framework...
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You're using h:selectOneRadio in a h:dataTable? That is indeed tricky.

Glad you fixed it after all.
 
 
subject: JSF "Update Model Values" phase exception