-1

当输入日期正确时,我有一个网页必须下载 XLS,但如果它们不正确,它必须显示一条消息并停止下载过程。

一切正常,当日期不正确时,我会建议用户,但每次单击按钮时都会打开一个新选项卡。如果日期正确,它会打开一个新选项卡,但在下载 XLS 时它会关闭,如果它不正确,它会建议用户,但它会打开新选项卡并且不会关闭它。如何修复它并且不打开新标签?

我把我的代码放在下面:

HTML:

        <div class="botonera">
            <a4j:commandLink id="regimenConcertadoLink"
                styleClass="botonAplicacionTXT"
                action="#{descargaInformesBean.validarInformeRegimenConcertado()}"
                oncomplete="if(#{descargaInformesBean.informeRegimenConcertadoValido}){#{rich:element('descargaInforme')}.onclick();}"
                status="waitStatus">
                <h:outputText value="Descargar Informe" />
                <h:graphicImage value="/img/ico_descargar.gif"
                    alt="Descargar Informe"
                    title="Descargar Informe" />
                <f:param name="requiredValidator"
                    value="requiredValidator" />
            </a4j:commandLink>
            <h:commandLink id="descargaInforme"
                styleClass="botonAplicacionTXT" target="_blank"
                action="#{descargaInformesBean.descargarInformeIngresos()}">
            </h:commandLink>
        </div>

爪哇:

 public void descargarInformeIngresos() throws ServiceException, IOException {        
    if ((filtroFechaDesde != null && filtroFechaHasta != null) || (filtroFechaIngresoDesde != null && filtroFechaIngresoHasta != null)) {
        //DOXMLSTUFF 
    }else {
        AtlasFacesUtils.addErrorMessageFromBundle("error.fecha.vacia");
    }
}

正如您在代码中看到的那样,如果两个日期都为空,我什么都不做并显示一条消息来建议用户,这工作正常,但仍会打开一个新选项卡,我不想这样做

谢谢!

4

1 回答 1

2

我相信这是由于您使用的目标标签属性引起的。这

target="_blank"打开一个新标签

尝试将其更改为

target="_self"看看它是否修复它。

于 2021-10-26T09:12:52.097 回答