Mike:

Thanks for the t:buffer tip. It did exactly the trick. This was much better/easier than what I was going to do.


My page pretty much worked out like the following.

       <h:commandLink action="#{bean.exportToExcel}">
           <h:outputText value="Export to Excel"/>
</h:commandLink>
       <t:buffer into="#{bean.dtBuffer}">
           <t:dataTable... stuff
       </t:buffer>

   <h:outputText value="#{bean.dtBuffer}" escape="false"/>

My exportToExcel method looks something like:

           String fileName = "exportedExcel.xls";
       String contentType = "application/vnd.ms-excel";
       FacesContext fctx = FacesContext.getCurrentInstance();
HttpServletResponse resp = (HttpServletResponse)fc.getExternalContext().getResponse(); response.setHeader("Content-disposition", "attachment; filename=" + fileName);
       response.setContentType(contentType);
       PrintWriter out = response.getWriter();
       out.print(dtBuffer);
       fc.responseComplete();

Dennis

Reply via email to