我有以下< p:dialog>
<p:dialog id="dlgDownload" header="#{appmsg['header.download.popup']}" widgetvar="downloadDlg" resizable="true" modal="true" closable="true" width="640" dynamic="false"> <h:form id="frmDownload"> <ui:include src="downloadDialog.xhtml" /> </h:form> </p:dialog>
包含文件包含以下下载按钮:
<p:commandButton id="btnDlgDownload" value="#{appmsg['action.download.label']}" title="#{appmsg['action.download.label']}" icon="ui-icon-arrowthickstop-1-s" ajax="false" oncomplete="if (!args.validationFailed){downloadDlg.hide();} else {downloadDlg.show();}" process="@this" update=":#{p:component('pnlDownload')}" > <p:fileDownload value="#{downloadController.downloadFile()}" /> </p:commandButton>
这使用< p:fileDownload>为了下载文件,这意味着我必须使用ajax =“false”作为< p:fileDownload>引起.
但是如果对话框中存在验证失败,那么我会看到对话框窗口关闭.我希望错误消息显示在对话框窗口中而不是主页面中.
@Balusc请找我对SSCCE的尝试
基本上有一个parent.xhtml下载按钮所在的位置,并且p:对话框中嵌入了downloadDialog.xhtml
<p:messages id="globalMessages" globalOnly="true" showDetail="true" showSummary="true" closable="true" /> <h:form = "parentForm" > <p:commandButton id="btnDownload" value="Download" title="Download" icon="ui-icon-arrowthickstop-1-s" onclick="downloadDlg.show();"> </p:commandButton> </h:form> <p:dialog id="dlgDownload" header="Download" widgetvar="downloadDlg" resizable="true" modal="true" closable="true" width="640" dynamic="false" visible="#{frmDownload.submitted and facesContext.validationFailed}"> <h:form id="frmDownload" binding="#{frmDownload}"> <ui:include src="downloadDialog.xhtml" /> </h:form> </p:dialog>
在里面下载Dialog.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:pe="http://primefaces.org/ui/extensions"> <p:outputPanel id="pnlDownload"> <h:panelGrid id="datedisplayGrid" columns="4" style="margin-bottom:10px" cellpadding="5" rendered="#{downloadForm.displayDates}"> <p:calendar id="strtdt" readonlyInput="true" size="12" value="#{downloadForm.startDate}" > </p:calendar> <h:outputText value="#{appmsg['label.to']}" /> <p:calendar id="enddt" readonlyInput="true" size="12" value="#{downloadForm.endDate}" pattern="#{dateFormatting.shortDateFormat}" navigator="true" > <f:validator validatorId="daterangeValidator" /> <f:attribute name="startDate" value=":#{p:component('strtdt')}" /> </p:calendar> <p:message id="dateError" for="enddt" showDetail="true" showSummary="false"></p:message> </h:panelGrid> <p:commandButton id="btnDlgDownload" value="Download" title="Download" icon="ui-icon-arrowthickstop-1-s" ajax="false" oncomplete="if(!args.validationFailed)downloadDlg.hide();" > <p:fileDownload value="#{downloadController.downloadFile()}" /> </p:commandButton> <p:button id="btnDlgCancel" value="#{webmsg['action.cancel']}" onclick="downloadDlg.hide(); return false" href="#" /> </p:panel> </p:outputPanel> </ui:composition>
当我点击对话框窗口上的下载按钮时,错误将显示在父html上,并且对话框保持关闭状态.但是,当我点击父页面上的下载按钮时,对话框窗口重新出现并在内部对话框窗口中包含错误消息.
谢谢你的帮助.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。