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

    StatusPanel

    leandro godoy Apprentice

      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.