0 Replies Latest reply on Sep 29, 2011 6:52 AM by Mader Levap

    Redirecting to PDF generation does not finish properly

    Mader Levap Newbie
      I have simple link with image, spinner (a4j:status) and redirection to PDF generation in .pages.xml.

      Example file .xhtml:
      <a4j:region id="opt_execute">
        <a4j:commandLink action="#{somePDFgenerator.preparePDF()}">
          <h:graphicImage value="/img/icons/some_cool_icon.png" styleClass="tableIcon" />
        </a4j:commandLink>

        <a4j:status for="opt_execute">
          <f:facet name="start">
            <h:graphicImage value="/img/icons/tbl_spinner.gif" styleClass="spinner" />
          </f:facet>
          <f:facet name="stop">
            <h:graphicImage value="/img/icons/tbl_filler.png" styleClass="spinner" />
          </f:facet>
        </a4j:status>
      </a4j:region>

      Bean somePDFgenerator prepares data to show in PDF.
      In .page.xml:
        <navigation from-action="#{somePDFgenerator.preparePDF()}">
          <redirect view-id="/generate/pdf/document_template.xhtml" />
        </navigation>

      File document_template.xhtml is standard seam PDF with p:document and all of that.

      <p:document ...
        disposition="attachment"
        fileName="whatever.pdf">
      ...
      </p:document>

      Problem: after clicking on link, PDF generates and is retrieved by browser as expected. But process halts instead of ending (spinner does not vanish or animate, it just... stops).
      It causes serious repercussions when I try to prevent multiple clicks (it likes to barf exceptions and generally slows system) with ignoreDupResponses, queue it etc. In this case second and later clicks do not work. Only refreshing entire page helps.
      It gets only worse with table, where in each row is clickable icon to generate PDF for given row. Without any safeties, clicking like monkey rapes server. With ignoreDupResponses and the like, you can click only once for each row. Even if you refresh table (NOT page, just reload data and rerender table). Oh pain, pain...
      What I can do?