I have a jsf page with a link for calling a search with Ajax. The link is automatically clicked with javascript. The form is in several instances of a portlet in liferay. Usually, everything works fine, but sometimes, the listener is not called.
In the portlet (I added the binding attribute that was missing in my first edit):
<h:form id="result">
...
<h:commandLink id="launch" binding="#{resultBackingBean.launchSearch}">
<f:ajax event="click" render="errors content debug" listener="#{resultBackingBean.doSearch}" />
</h:commandLink>
...
</h:form>
When it works, I have the following traces:
12:55:10,476 DEBUG AFTER phaseId=[RESTORE_VIEW 1] viewId=[/views/search_result.xhtml]
12:55:10,476 DEBUG BEFORE phaseId=[APPLY_REQUEST_VALUES 2] viewId=[/views/search_result.xhtml]
12:55:10,476 DEBUG AFTER phaseId=[APPLY_REQUEST_VALUES 2] viewId=[/views/search_result.xhtml]
12:55:10,476 DEBUG BEFORE phaseId=[PROCESS_VALIDATIONS 3] viewId=[/views/search_result.xhtml]
12:55:10,476 DEBUG AFTER phaseId=[PROCESS_VALIDATIONS 3] viewId=[/views/search_result.xhtml]
12:55:10,486 DEBUG BEFORE phaseId=[UPDATE_MODEL_VALUES 4] viewId=[/views/search_result.xhtml]
12:55:10,486 DEBUG AFTER phaseId=[UPDATE_MODEL_VALUES 4] viewId=[/views/search_result.xhtml]
12:55:10,486 DEBUG BEFORE phaseId=[INVOKE_APPLICATION 5] viewId=[/views/search_result.xhtml]
12:55:10,486 DEBUG doSearch called
12:55:10,486 DEBUG AFTER phaseId=[INVOKE_APPLICATION 5] viewId=[/views/search_result.xhtml]
12:55:10,486 DEBUG BEFORE phaseId=[RENDER_RESPONSE 6] viewId=[/views/search_result.xhtml]
12:55:10,496 DEBUG AFTER phaseId=[RENDER_RESPONSE 6] viewId=[/views/search_result.xhtml]
I can see my own debug trace doSearch called. But sometimes, after page reloading, I do not see my trace, the listener is never called. I always have the Detected Ajax ResourceRequest trace, but there is nothing between BEFORE INVOKE_APPLICATION and AFTER INVOKE_APPLICATION.
If I want the page to work again, I have to reload it. As if something wrong was sometimes occurring during some loading, as the behavior can change only after the page is reloaded.
I tried to change the scope of the bean with doSearch (from viewScope to sessionScope), I tried to set immediate="true" for the f:ajax, I tried to use a4j:ajax, but I still have the same behavior that I don't understand... Why? :(
Edit:
For information, with findbugs, I see the ajax request. In the working case, with updates for fields to render, and in the not working case, with an almost empty partial response:
<partial-response>
<changes>
<update id="javax.faces.ViewState">6791417547372597471:4319149946307207422</update>
</changes>
</partial-response>