mardi 26 octobre 2021

My page is opening a new tab and I don't know why

I have a webpage that have to download an XLS when the input dates are correct, but if they are not correct, it has to show a message and stopped the dowload process.

All works fine, and I advice the user when the dates are incorrect, but it opens a new tab everytime I click on the button. If the dates are correct, it opens a new tab, but it is closed when the XLS is downloaded, if it is not correct, it advices the user, but it opens the new tab and doesn't close it. How can I fix it and don't open a new tab?

I put my code below:

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>

JAVA:

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

As you see in the code, if both of the dates are null, I don't do anything and show a message to advice the user, this works fine, but still opens a new tab and I don't want to do that

Thanks!




Aucun commentaire:

Enregistrer un commentaire