3 Replies Latest reply on Jan 3, 2011 12:56 PM by Bruce Randall

    a4j:commandButton and Apache POI

    Bruce Randall Newbie

      I know this is a little out of place but I was wondering if anyone has used Apache POI with an ajax event component, a4j:commandButton or a4j:commandLink.


      Issue: All is fine using h:commandButton. However, I wanted to use a rich:modalPanel while the Excel workbook was being created. So I used



      <a4j:region id="rptExport" renderRegionOnly="true">
             <a4j:commandButton id="rptExportBtn" immediate="false"
              <rich:modalPanel id="exportModalPanel" autosized="true">
                    <h:panelGrid id="exportPanel" columns="2" style="text-align:center;">
                          <h:outputLabel id="exportText" value="Exporting" styleClass="fieldLabel"/>
                               <h:graphicImage id="eportImg" value="/images/indicator.gif"/>



      The actionListener is fired, the modal panel is displayed but the Excel app is not launched and the modal panel never goes away as if oncomplete never happens. I suspect it has to do with FacesContext fc.responseComplete();

        • 1. Re: a4j:commandButton and Apache POI
          Ilya Sorokoumov Master

          I'm afraid this is not possible. Because when you use h:commandButton you send some specital headers with response and that's why browser opens your resonse as a workbook in Excel. But you can't possibly open a workbook inside your html page. I think you have only one option you should use some JS components which look like Excel. See http://www.treegrid.com/treegrid/www/ for example. I'm sorry if I disappointed you.


          P.S. May be folks have other opinions.

          1 of 1 people found this helpful
          • 2. Re: a4j:commandButton and Apache POI
            Ilya Shaikovsky Master

            Ilya is right, you can't use ajax controls to initiate downloads, excel's PDF's and so on passing to client. So you have to use h:commandButton and probably trigger some indication using its onclick.

            • 3. Re: a4j:commandButton and Apache POI
              Bruce Randall Newbie

              Many thanks for looking at this! I travelled down the alternate road   by triggering a modal panel using an a4j:support because the   h:commandButton does not support oncomplete. The problem is the response   never triggers the oncomplete, probably because the export action   forced the reponse complete. The best solution I came up with is to   allow the user to close the modal panel manually which means they can   start firing other events before the export is complete which is what I   was hoping to prevent. Que sera sera


              Thanks for the help.