5 Replies Latest reply: Feb 14, 2013 10:34 AM by aalopez RSS

    GlassPane for af:fileDownloadListener

    aalopez
      Hello All. Using Jdev 11.1.2.3.

      I'm generating reports from the server using JasperReports. I have displayed a form with input components so the user can insert values for the parameters that then I pass to the report. As I needed to validate these input components before generating the report, I'm using the technique of having a visible="false" button with an af:fileDownloadListener tag inside and invoking the action from JavaScript. The following code WORKS just great:

      ================================================================================================
      in my page:

      ...

      <af:commandButton text="" id="HiddenBtn" clientComponent="true" visible="false" binding="#{DynamicView.btnHidden}">
      <af:fileDownloadActionListener method="#{DynamicView.runReport}"/>
      </af:commandButton>

      <af:commandButton id="btnGenerar" text="Generate" binding="#{DynamicView.btnGenerar}"
      actionListener="#{DynamicView.btnGenerar_actionListener}" clientComponent="true" partialSubmit="true"/>

      ...

      <af:resource type="javascript">

      function customHandler(event) {
      var exportCmd = AdfPage.PAGE.findComponentByAbsoluteId(event);
      var actionEvent = new AdfActionEvent(exportCmd);
      actionEvent.queue();
      }

      </af:resource>

      ...

      ================================================================================================

      in my bean:

      ...

      public void btnGenerar_actionListener(ActionEvent actionEvent) {
      //Some validations...

      FacesContext context = JSFUtils.getFacesContext();
      String btnHiddenId = this.btnHidden.getClientId(context);
      ExtendedRenderKitService erks = Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
      erks.addScript(context, "customHandler('" + btnHiddenId + "');");

      }

      public void runReport(FacesContext facesContext, OutputStream outputStream) {
      //code for generating Jasper Report to the outputStream
      }
      ...

      ================================================================================================


      This Works really good! But sometimes the reports take a while when generating and I want to implement a GlassPane as described here:

      [http://www.oracle.com/technetwork/developer-tools/adf/learnmore/27-long-running-queries-169166.pdf|http://www.oracle.com/technetwork/developer-tools/adf/learnmore/27-long-running-queries-169166.pdf]

      What I don't know is where am I supposed to put the:

      <af:clientListener method="enforcePreventUserInput" type="action"/>

      I have put it inside the button the user clicks, but if doing so, the popup is shown only for a few seconds, I suppose is because the button's action method finishes... but what I really want is to show the popup when the af:fileDownloadListener is invoked (visible="false" button).
      When I put it inside the button with the af:fileDownloadlistener then the popup is never shown.

      Any idea on how to accomplish this?

      Regards,
      Alexis
        • 1. Re: GlassPane for af:fileDownloadListener
          Frank Nimphius-Oracle
          Hi,

          I would try putting it on the hidden button you queue to invoke the file download. Just make sure the button has its clientComponent property set to true

          Frank
          • 2. Re: GlassPane for af:fileDownloadListener
            aalopez
            Hi Frank, Thanks for your quick answer.

            I did what you suggested:

            ========================================================================================================
            ...

            <af:commandButton text="" id="HiddenBtn" clientComponent="true" visible="false" binding="#{DynamicView.btnHidden}">
            <af:clientListener method="enforcePreventUserInput" type="action"/>
            <af:fileDownloadActionListener method="#{DynamicView.runReport}"/>
            </af:commandButton>

            ...
            ========================================================================================================

            However it didn't work. When debugging I notice that the function enforcePreventUserInput(evt) is being invoke as expected, but the JavaScript call back handler, function handleBusyState(evt), is never called so the popup is never shown nor hidden. I wonder why is the callback handler not being invoked?

            Regards,
            Alexis
            • 3. Re: GlassPane for af:fileDownloadActionListener
              aalopez
              There is something odd with the af:fileDownloadActionListener. When I remove that tag from inside the hidden button, the popup appears and then disappears as expected.

              Any ideas?

              Regards,
              Alexis

              Edited by: aalopez on Feb 12, 2013 2:35 PM

              Edited by: aalopez on Feb 12, 2013 2:36 PM
              • 4. Re: GlassPane for af:fileDownloadActionListener
                Frank Nimphius-Oracle
                Hi,

                I think what happens is that the fileDownloadActionListener (as it operates in JavaScript on the client) just cancels the action event so that no further processing occurs. As an alternative, can you try and launch a custom popup from Java before invoking the hidden button?

                RichPopup popup = ... access to the popup
                RichPopup.PopupHints hints = new RichPopup.PopupHints();
                popup.show();

                You then invoke the hidden button. At the end of the file uploade process you again look-up the popup and call hide() on it

                Frank
                • 5. Re: GlassPane for af:fileDownloadActionListener
                  aalopez
                  Frank, thanks for your suggestion. I launched the popup before the hidden button was queue and the popup displays OK. However, after the download starts and finishes, I can't access the popup in order to hide it, I tried with javascript but it doesn't get invoked, also tried from the managed bean, the code is executed but nothing happened.
                  I think, I'm going to look another way to download the file and try again.

                  Regards,
                  Alexis

                  Edited by: aalopez on Feb 14, 2013 8:34 AM