Showing posts with label jsf. Show all posts
Showing posts with label jsf. Show all posts

Sunday, February 3, 2008

JSF does not call action in managed bean

In the few previous days I had the same problem more than once. For some reason, action in managed bean was not called from JSF page. I was searching through the Internet but couldn't find any real help although more than one person had the same or very similar problem.

Here is situation I had. There is JSF page with the form, some input fields and button that should call action on managed bean. When you click the button action should be called but nothing happens. There is no error displayed nor you can find out where the call is lost. After some investigation it turned out that this appear each time when JSF does not succeed to map values form page to values in managed bean. But there is no clue which values are not binded correctly. I know this is validation and conversion problem and in some cases immediate="true" should solve the problem but in my case even that didn't help.

So how do I solve such situations. There is no straightforward solution for this but following should work in the most of the cases:
Remove field by field in your JSF page. Then redeploy application and try if your method works. Maybe even you need to remove combination of fields to make your action being called.
When you find out which field(s) are cause of the problems you can concentrate on those fields and solve the problem.

What I found out in my cases was:
  • Once setter I used was not of void type but returned some value. JSF didn't accept this return value
  • Once setter I used was throwing RunTimeException that was not handled correctly
Anyway, action not being called without any message or stacktrace displayed can be very annoying. It is very hard (at least for me) to find out what is happening and I hope that this simple but time consuming process will help somebody else as it did help me in few situations.