interesting in putting this to our wiki ?


On 7/14/06, Dennis Gesker <[EMAIL PROTECTED]> wrote:
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




--
Matthias Wessendorf

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Reply via email to