2
votes

I am facing very weird issue with JSF2.0 Ajax Tag. Below are the steps that causes an issue for me

  1. My project uses JSF2.0 and Spring 3.0. The JSF is wired to spring controller and life cycle is managed by Spring.
  2. My Controller is Request Scoped.

Everything works fine till this point

i have a selectOne dropdown and on selection of a value on drop down it renders bottom portion of screen which has another dropdown. I use a rendered attribute on a parent panelgroup to show and hide this drop down.

However for the newly rendered drop down on selection of a value the ajax listener(F:ajax tag defined inside it) is not getting invoked. I see the following happening

  1. The bean is reintialized as it is request scope.I see my postconstruct getting executed.
  2. i see success message in the data object in client.

Only thing missing is that the listener method is not invoked.

Is there anyway to debug the life cycle and find what is going wrong?

1

1 Answers

1
votes

If the rendered attribute of one of the parent components of <f:ajax> evaluates false during processing the ajax request, then the ajax action listener won't be invoked.

A request scoped bean is recreated on every single request, so all its properties would be resetted to default, unless initialized otherwise in the (post)constructor. If the property behind the rendered attribute isn't properly reinitialized based on some request parameters, then it would evaluate false like as on the initial request.

To fix it, you'd need to do proper initialization in bean's (post)constructor based on request parameters or just put the bean in the JSF view scope.

See also: