好吧,我发现出了什么问题。所以:
Appearance of the problem:
I've got a page for user data. Some input items and command buttons. When clicking "Create" button, input data is checked out. If data is ok user is created and table of users appears, or when there are errors - errors messages appear and user stays on the same page:
我发现一些不稳定的行为。第一次单击(操作)时没有发生任何事情,只有第二次和后续操作才会产生效果。但。这种行为是related我使用的网络浏览器类型。
所有操作均从网络浏览器中的第一次单击开始发生:epphany 和 konqueror。尽管在火狐和铬中我观察到了我上面描述的这种不稳定的行为。命令按钮的代码是:
<h:commandButton value="#{msg.butCreate}" action="#{userBb.formCreate()}" rendered="#{userBb.chosenNew}"/>
不同网络浏览器中的不同行为。
原因。@Balusc 在他的文章中列举了原因note https://stackoverflow.com/a/2120183/1331274,我第一次大致读到。确实是pt。 7.
解决方案。我尝试以这种方式更改按钮声明:
<h:commandButton value="#{msg.butCreate}" action="#{userBb.formCreate()}" rendered="#{userBb.chosenNew}">
<f:ajax render="userForm"/>
</h:commandButton>
其中 userForm 是 h:form 的正确 ID。没有结果,仍然只有第二次和后续点击有效果 - 显示错误消息。
因此,我更改了上一页的声明命令按钮,该按钮调用了不稳定的行为页面。原来是:
<p:commandButton value="#{msg.butNew}" action="#{userBb.actionNew()}"/>
primefaces 命令按钮。就是这样,正如 Balusc 所写:“如果带有 UICommand 按钮的父级已预先通过 ajax 请求渲染/更新,那么第一个动作总是会失败。”
所以我将声明更改为:
<p:commandButton value="#{msg.butNew}" action="#{userBb.actionNew()}" ajax="false"/>
就是这样。对于第一个操作,它在任何浏览器中都可以正常工作。