1

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>
bcassand
  • 41
  • 2
  • Do you have an `` within another ``? this is usually responsible for inconsistent behaviour in view actions – kolossus Jun 11 '13 at 05:26
  • I only have one ``, with mainly `h:outputText`. – bcassand Jun 11 '13 at 07:36
  • Isn't the session/view just expired? By default, it expires after 30 minutes of inactivity and by default, ajax requests do not have an exception handler and end up with totally no feedback in case of exceptions (and exactly this kind of partial response with a changed view state). You should however see a `ViewExpiredException` in the server logs. Did you thought about reading the server logs? See also http://stackoverflow.com/questions/3642919/javax-faces-application-viewexpiredexception-view-could-not-be-restored/3642969#3642969 – BalusC Jun 11 '13 at 12:50
  • @BalusC It is not session expiration. I can have the issue very quickly after login. And once I have the issue, it can work again if the page is reloaded (with data from session, so the session is still good). – bcassand Jun 11 '13 at 12:58
  • Are you logging-in by an ajax or normal request? It should be done by a normal request or at least perform a redirect after login. – BalusC Jun 11 '13 at 12:59
  • @BalusC it's done by normal request. And the page with ajax is opened only after a check that some data are available in session. – bcassand Jun 11 '13 at 13:51

0 Answers0