I have a search result page with a "Show more results" button. The backing bean is session-scoped and we use a preRenderView to execute the search method in the backing bean:
<f:event type="preRenderView" listener="#{SearchBean.searchSolutions}" />
The "Show more results" button is defined like this:
<h:commandButton action="#{SearchBean.onClickShowMoreResults()}">
<f:ajax disabled="false" render=":searchResultsForm"/>
</h:commandButton>
Here is the problem I have and the steps to reproduce :
I tried skipping the ajax requests in the listener method (as explained here) and it solves the problem, but this is not possible for me because there are ajax requests that need to execute the listener method (changing search criteras).
Is there something I don't understand about the preRenderView or is there another way to achieve what I am trying to do ?
Thanks for the help!
Since I got no answer, I found a workaround this problem.
I made sure to have no ajax calls to the listener method (doing some sacrifices) and used BalusC's answer in this thread.
Using :
if (FacesContext.getCurrentInstance().getPartialViewContext().isAjaxRequest()) {
return; // Skip ajax requests.
}
in the listener method solves this problem.