3 Replies Latest reply on Apr 12, 2010 6:57 AM by lgweb

    StatusPanel

    lgweb

      Why execute by <a4J:commandButton..>  this . pdf not rendering.

      see:

       

       

      1:ok rendering .pdf

      <h:commandButton actionListener="#{mBRelatorio.actionGerarRelatorio}"
                      value="Gerar Relatório" styleClass="btn" id="btnGerar">
                  </h:commandButton>

       

      2: Error not rendering .pdf,
                  <a4j:commandButton actionListener="#{mBRelatorio.actionGerarRelatorio}"
                      value="Gerar Relatório" styleClass="btn" id="btnGerar"
                      ajaxSingle="true" status="status">
                  </a4j:commandButton>

       

      <a4j:status onstart="Richfaces.showModalPanel('statusPanel')"
                      id="status" onstop="Richfaces.hideModalPanel('statusPanel')">
                  </a4j:status>

       

       

      public void actionGerarRelatorio(ActionEvent evt) {
              try {
                  if (validaDatas(dataInicial, dataFinal)) {
                      FacesContext facesContext = FacesContext.getCurrentInstance();
                      byte[] b = executarRelatorio();
                      if (b != null) {
                          HttpServletResponse res = (HttpServletResponse) facesContext
                                  .getExternalContext().getResponse();
                          res.setContentType("application/pdf");
                          //res.setContentType("application/octet-stream");
                          OutputStream out = res.getOutputStream();
                          out.write(b);                   
                          out.flush();
                          FacesContext.getCurrentInstance().responseComplete();
                      } else {
                          FacesContext.getCurrentInstance().addMessage(
                                  "Error",
                                  new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                          "Selecione um tipo de relatório a gerar",""));
                      }

       

                  }

       

              } catch (IOException e) {
                  e.printStackTrace();
              }

       

          }

       

       

       

      please helpe me.

      thanks.

        • 1. Re: StatusPanel
          lgweb

          I'll try to explain better, when I run the above method using a (h: commandButon) it performs and displays the report in firefox, but when I use (a4J: comandButton) he'll never displays the report but a lot of text on screen messed up
          must use (a4j: CommandButton) because I have to show the standby screen.
          What's wrong with my code?
          any help and welcome, can someone help?
          Thank you.

          • 2. Re: StatusPanel
            nbelaevski

            Hi Leandro,

             

            It's not possible to display/save binary files transferred via AJAX request. As far as I know there's no reliable way of implementing status for such cases, but you can search the forum - maybe you'll find something that works for you.

            • 3. Re: StatusPanel
              lgweb

              ok,thank you nick .