jsf - 用另一个模态 p:dialog 覆盖模态 p:dialog
问题描述
首先 - 我是 PrimeFaces 的新手,我试图在另一个已经生成的对话框之上显示一个警告对话框。
查看代码看起来像(简化):
<p:dialog id="userDialog" header="User Account" widgetVar="userDialogView" modal="true" resizable="true" closable="fasle" showHeader="true" height="400" width="880px">
<h:form id="dataDialogForm">
...
</h:form>
</p:dialog>
<p:dialog id="warnDialog" header="Warning!" widgetVar="warnDialog" modal="true" appendTo="@(body)" height="300px" width="600px" resizable="false">
<h:outputText value="You are trying to delete. Do you want to proceed? Yes/No" />
</p:dialog>
和控制器warnDialog
产生它
RequestContext.getCurrentInstance().execute("showDialog('warnDialog')");
warnDialog
正在正确生成,但显示在userDialog
对话框下而不是在其顶部。
应用正在使用 PrimeFaces v6.0
org.primefaces.webapp.PostConstructApplicationEventListener.processEvent Running on PrimeFaces 6.0
编辑:
测试confirmDialog
代码(简化)如下:
<p:dialog id="userDialog" header="User Account" widgetVar="userDialogView" modal="true" resizable="true" closable="fasle" showHeader="true" height="400" width="880px">
<h:form id="dataDialogForm">
...
<p:confirmDialog widgetVar="warnDialog" header="Confirmation" severity="warn" modal="true" resizable="false" position="top,left">
<f:facet name="message">
You are trying to delete. Do you want to proceed?
</f:facet>
<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="pi pi-check" />
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="pi pi-times" />
</p:confirmDialog>
</h:form>
</p:dialog>
那个没有产生阻塞覆盖userDialog
也没有定位到视口的左上角而不是定位到触发的元素confirmDialog
。
解决方案
我通过覆盖 PrimeFaces CSS 解决了我的问题,由于某种原因,它在 5.x 和 6.x 版本中没有正确处理覆盖对话框(与普通 jQuery UI 或 Bootstrap 相比)。
我的解决方案如下所示:
<p:dialog id="userDialog" header="User Account" widgetVar="userDialogView" modal="true" resizable="true" closable="fasle" showHeader="true" height="400" width="880px">
<h:form id="dataDialogForm">
...
</h:form>
</p:dialog>
<p:dialog id="warnDialog" header="Warning!" widgetVar="warnDialog" modal="true" height="300px" width="600px" resizable="false" styleClass="dialogWarn-fix">
<h:outputText value="You are trying to delete. Do you want to proceed? Yes/No" />
</p:dialog>
和它的CSS:
.dialogWarn-fix {
z-index: 9999 !important;
}
推荐阅读
- html - 如何减小 CSS 卡片显示中图像的大小
- r - 提高 R 中 data.table 中两列的粘贴速度(可重现)
- php - php 计算器 - Switch 语句问题
- spring-boot - Togglz 不从 application.yml 获取 Spring-Boot 配置
- webpack - webpack 开发服务器未构建和重新加载 index.html
- java - Spring Boot 电子邮件发送抛出 SocketTimeoutException: Read timed out
- node.js - 如何使用 Bale bot 向群组发送消息?
- angular - ngFor 内部的数据绑定
- jquery - 使用 jQuery 删除元素后,AngularJS 观察者仍然触发?
- python - 使用 spyder (python) 打开一个网站并根据时间刷新它