【发布时间】:2016-08-16 09:58:10
【问题描述】:
我在最少两个屏幕/视图上面临这个问题,其中有许多在新窗口中打开对话框的命令按钮。我正在使用 Primefaces 5.3.5 和 JSF Mojarra 2.2.8。这些动作/动作监听器在弹出窗口中打开一个新对话框。第一个命令按钮总是打开新对话框,但其他命令按钮什么都不做。
<h:form id="dbuserForm">
<!-- New User Button. This one fires a dialog -->
<p:commandButton id="newUserGroupBtn" value="#{msg.WEB_BUTTONS_NEW}" style="margin-right: 2px;" actionListener="#{appUserData.toggleNewModal}" icon="fa fa-plus" accesskey="n" update="@form">
<p:ajax event="dialogReturn" update="@form" />
</p:commandButton>
<p:dataTable id="tableDbUser" scrollable="true" width="100%" value="#{tabDbUser.listArray}" var="item" selectionMode="single" rowKey="#{item.idbuserId}">
<!-- Delete User Button -->
<p:column>
<p:commandButton id="deleteAppUserBtn" value="#{msg.WEB_BUTTONS_DELETE}" style="margin-right: 2px;" actionListener="#{appUserData.toggleDeleteModal}" icon="fa fa-remove" accesskey="o" update="@form" disabled="#{appUserData.selectedUserName eq null or appUserData.selectedUserName eq ''}">
<p:ajax event="dialogReturn" update="@form" />
</p:commandButton>
</p:column>
<!-- Modify User Button -->
<p:column>
<p:commandButton id="modifyAppUserBtn" value="#{msg.WEB_BUTTONS_OPEN}" style="margin-right: 2px;" actionListener="#{appUserData.toggleChangeModal}" icon="fa fa-edit" accesskey="o" update="@form" disabled="#{appUserData.selectedUserName eq null or appUserData.selectedUserName eq ''}">
<p:ajax event="dialogReturn" update="@form" />
</p:column>
</p:dataTable>
</h:form>
和我的后端 bean
@Override
public void toggleNewModal(ActionEvent event) {
RequestContext.getCurrentInstance().openDialog("/dialogs/new-dbuser");
}
@Override
public void toggleDeleteModal(ActionEvent event) {
RequestContext.getCurrentInstance().openDialog("/dialogs/del-report-dialog");
}
public void togglePasswordModal() {
RequestContext.getCurrentInstance().openDialog("/dialogs/modify-dbuser");
}
注意 新用户按钮只会触发此对话框(new-dbuser)。其他按钮什么也没触发,但它们是可点击的,我看不到任何错误。
我不知道这是否重要,但我的 bean 被配置为请求范围。
我知道这是 SO 中非常讨论的话题,但我还没有找到任何适合我的解决方案。感谢您的任何帮助。我真的被困住了,因为我没有看到任何错误。请有建设性。
【问题讨论】:
-
“我知道这是 SO 中非常讨论的话题,但我没有找到任何适合我的解决方案。” 请参阅 How to Ask。发布您发现的内容以及为什么它不起作用。并发布minimal reproducible example
-
@Kukeltje 谢谢,就是这样。请立即查看并注意新用户按钮只会触发一个对话框。
-
关于这个问题还有哪些其他主题?他们没有为您解决什么问题。这就是我的意思。并尝试更改顺序?然后会发生什么?
-
“我不知道这是否重要,但我的 bean 被配置为请求范围。” 尝试更改范围?
-
@Kukeltje 谢谢,就是这样。我将它们改回会话范围,它们现在触发了。
标签: ajax jsf-2 primefaces