我在 JSF 中可以进行的 ajax 调用数量是否有限制?
我正在 IBM Wepsphere Portal 5.1 环境中使用 RAD 7 开发一个 portlet。我有各种字段,可以通过 ajax 调用在后端填充对象。这是为了在用户离开页面而不提交数据时保留数据。输入是弹出窗口和下拉菜单的组合。当用户想要永久存储数据时,他们会单击提交按钮。
我注意到,当您在页面上填写超过一定数量的字段时,您需要单击提交按钮两次。第一次提交似乎只是刷新页面,并且没有调用命令按钮后面的操作。第二个提交数据。
我对此进行了大量测试,并意识到在提交按钮第一次无法工作之前,我可以执行的 ajax 调用似乎有 7 次限制。即使我只更改一个字段 8 次也会失败。
不知何故,超过 7 次调用会使页面处于不同的状态。离开该页面即可修复该问题。即,如果您填写了所有字段,然后转到菜单中的其他页面,然后返回,则可以通过第一次单击来提交。
jsp 中的典型下拉列表如下所示:
<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>
支持 bean 中的方法如下所示:
处理选定的值:
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();
}
填充下拉列表中的选项:
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;
}
提交按钮:
<hx:commandExButton
type="submit" value="Save " styleClass="commandExButton"
id="saveButton" action="#{pc_Footer.doSaveAction}" rendered="#{pc_Footer.showSave}" />
没有什么不寻常的 我本以为,但我仍然得到问题。
以前有人见过这样的事情吗?
问候
比尔
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的问题..我找到的解决方案是 get;stop 正在产生这个问题...只需从behaviorAction 中删除 stop ..然后你可以进行 N 次 ajax 调用...
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...