0 Replies Latest reply: Jun 11, 2012 6:13 PM by Rafael Neves RSS

    error if using response.getOutPutStream in MB for download my report

    Rafael Neves Newbie

      Hi people,

       

       

      I don't understand this: I need return a archive in .xls format and if I set the property getOutPutStream in my HttpServletResponse, don't is possible obtain correct life cicle  of my component.

      I have the following:

      1.                 <a:region> 
      2.                 <a:commandButton  
      3.                     render="@form" 
      4.                     execute="@region" 
      5.                      
      6.                     value="Gerar RelatórioF" 
      7.                     actionListener="#{acoesRealizadasMB.gerarRealatorio}"  
      8.                     immediate="true"  /> 
      9.                  </a:region> 
      10.                 <h:commandButton type="button" value="Fechar" 
      11.                     onclick="closeFrame();" immediate="true" /> 
      12.                      
      13. <rich:popupPanel id="mpStatusF" modal="true" moveable="true" resizeable="false" followByScroll="false" width="80" height="70"
      14.     <div align="center"
      15.         <div> 
      16.             <h:graphicImage value="/images/loading.gif" alt="Carregando" /> 
      17.         </div> 
      18.         <div> 
      19.             <h:outputText value="#{message['aguarde']}" /> 
      20.         </div> 
      21.     </div> 
      22. </rich:popupPanel> 
      23.  
      24. <a:status id="teste" onstart="#{rich:component('mpStatusF')}.show()" onstop="#{rich:component('mpStatusF')}.hide()" />  

       

       

      and my MB are this form:

      1. private void enviarRelatorio(HSSFWorkbook wb) throws IOException { 
      2.     FacesContext context = FacesContext.getCurrentInstance(); 
      3.     HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); 
      4.     response.setDateHeader("Expires", 0); 
      5.     response.setHeader("Content-Disposition", "attachment; filename=acoesRealizadas.xls"); 
      6.     response.setContentType("application/octet-stream"); 
      7.     ServletOutputStream servletOutputStream = response.getOutputStream(); 
      8.     wb.write(servletOutputStream); 
      9.     servletOutputStream.flush(); 
      10.     servletOutputStream.close(); 
      11.     context.responseComplete(); 
      12. }

       

      anybody have this problem or have a possible solution?