Is there a limit to the number of ajax calls I can make in JSF?

909 Views Asked by At

I am developing a portlet with RAD 7 in an IBM Wepsphere portal 5.1 environment. I have various fields which poplate objects in the back end with ajax calls. This is in order to persist the data if the user navigates away from the page without submitting it. The inputs are a combination of popups and dropdowns. When the user wants to store the data permanently they then click a submit button.

I noticed that when you fill out more than a certain amount of fields on the page you need to click the submit button twice. The first submit seems to do just refresh the page, and the action behind the command button is not called. The second one submits the data.

I've done quite a lot of testing with this and realised that there seems to be a limit of 7 ajax calls I can do before the submit button wont work first time. Even if I just change one field 8 times it fails.

Somehow going over 7 calls leaves the page in a different state. Navigating away from the page will fix it. Ie if you fill out all the fields then go to a different page in the menu and then return, you can submit with the first click.

A typical dropdown in the jsp is like below:

<h:panelGroup id="resultGroup">
<h:selectOneMenu syleClass="selectOneMenu" id="menu2" value="#{pc_CallView.result}">    
<f:selectItems value="#{pc_CallView.results}" />
</h:selectOneMenu>
<hx:behavior  event="onchange" target="menu2" behaviorAction="get;stop" targetAction="resultGroup">
</hx:behavior></h:panelGroup> <hx:ajaxRefreshRequest target="resultGroup" id="ajaxRefreshRequest6" params="menu2">
<hx:ajaxRefreshRequest> target="resultGroup" id="ajaxRefreshRequest6" params="menu2"></hx:ajaxRefreshRequest>

The methods in the backing bean are like below:

To handle the selected value:

public String getResult(){

    String result = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("menu2");
    if(result!=null && !result.trim().equalsIgnoreCase("")){
    getHelper().getCallDetails().setResult(result);
    }       
    return getHelper().getCallDetails().getResult();
}

To populate the choices in the dropdown:

public List getResults(){       

List results = getHelper().getCallResults();
List resultSelectItemsList = new ArrayList();
Iterator it = results.iterator();
resultSelectItemsList.add(new SelectItem("","-- select --"));
while(it.hasNext()){
    ClientCallResult result = (ClientCallResult)it.next();
    resultSelectItemsList.add(new SelectItem(result.getId(),result.getResult()));
}

return resultSelectItemsList;

}

The submit button:

<hx:commandExButton
        type="submit" value="Save " styleClass="commandExButton"
        id="saveButton" action="#{pc_Footer.doSaveAction}" rendered="#{pc_Footer.showSave}" />

Nothing unusal I would have thought, but still I get the problem.

Has anyone seen anything like this before?

Regards

Bill

1

There are 1 best solutions below

0
On

I had faced same problem.. what solution I found is get;stop is making this issue... just remove the stop from behaviorAction.. then you can make N number of ajax calls...