Forum Stats

  • 3,770,906 Users
  • 2,253,180 Discussions
  • 7,875,653 Comments

Discussions

How to apply the waiting PopUp on fileDownloadListener

DanielD7777
DanielD7777 Member Posts: 45
edited Sep 20, 2018 12:56PM in JDeveloper and ADF

Hi experts I am writing you because of a problem that I have implementing a waiting pop up while the download process of a file is executing.

I have to implemented across several ADF applications that are part of 3 BPM process and other complementary apps.

I successfully implemented in some pages following the following tutorial with  some customization changes:

Ranjith Kumar's Blog: ADF : Show Pop Up while af:fileDownloadActionListener is taking long time to complete.

The changes that I did about the post above, is that instead of calling the af:poll component

and show the pop up by javascript I did it by java code because the activation of the poll did not work  by javascript.

The pages where I implemented have fragments and it work quite good.

But once I am trying to apply the same on the jspx/jsf pages that does not have fragment the following error appear once the fileDownloadListener is going to start the file writing.

pastedImage_2.png

The thing is that I really need to implement the waiting popUp in all the pages in this app, I am really concerned about this implementation.

This is my JSF code.

<af:link text="Invisible download Button " clientComponent="true" id="lInv"

visible="false">

      <af:fileDownloadActionListener filename="#{viewScope.RM011000VSBean.fileName}"

                                                                       method="#{viewScope.RM011000VSBean.downloadFile}"/>

</af:link>

     <af:link text="Download"

     actionListener="#{viewScope.RM011000VSBean.showPopUpANDTurnPollOn}"

     visible="#{not viewScope.RM011000VSBean.isUsuarioTemporal}" id="ll34">

</af:link>

   <af:popup id="popupEspera" contentDelivery="immediate">

               <af:dialog id="d2" type="none" closeIconVisible="false">

                  <af:panelGroupLayout id="pgl7" layout="vertical" halign="center">

                      <af:outputText value=" Transacci&#243;n en proceso, por favor espere..." id="ot11"/>

                       <af:panelGroupLayout id="pgl8">

                                <af:image source="/sbdcr/images/Loading Icon.gif" id="i1"

                                          inlineStyle="width:50px; height:50px;"/>

                         <af:spacer width="40" height="10" id="s8"/>

                   </af:panelGroupLayout>

             </af:panelGroupLayout>

       </af:dialog>

</af:popup>

   <af:poll id="poll" interval="-1" pollListener="#{viewScope.RM011000VSBean.pollListenerActive}"/>

This is the java method of the action listener (This method works perfectly):

   public void showPopUpANDTurnPollOn(ActionEvent ae) {

 

     logger.warning("DD IT WILL SHOW THE POPUP");

     RMCommons.showPopUp();

     this.downloading = true; // variable to indicate the poll once it execute that it will click the download link programmatically.

       logger.warning("DD IT WILL TURN THE POP UP ON WITH 4 SECONDS OF INTERVAL");

       RichPoll poll = (RichPoll) JSFUtils.findComponentInRoot("poll");

        if (null != poll) {

       poll.setInterval(4000);

        AdfFacesContext.getCurrentInstance().addPartialTarget(poll);

      }

    }// end of method

// Method showPopUp()  in RMCommons class (It works perfectly)

    public static void showPopUp() {

        RichPopup rPu = (RichPopup) JSFUtils.findComponentInRoot("popupEspera");

        RichPopup.PopupHints hints = new RichPopup.PopupHints();

        logger.warning("Popup obtenido: " + rPu);

        if (rPu != null) {

            logger.warning("### Popup no es nulo");

            logger.warning("### Probando variable de isInView" + rPu.isInView());

            rPu.show(hints);

            logger.warning("### Probando variable de isInView despues de ocultar" + rPu.isInView());

        }

    }

}

// Now the pollListener Active method, it works perfectly.

    public void pollListenerActive(PollEvent pollEvent) {

        RichPoll poll = (RichPoll) pollEvent.getComponent();

        if (!this.downloading) {// if is not downloading acording to  the variable

         RichPopup popUpEspera = (RichPopup) JSFUtils.findComponentInRoot("popupEspera");

        if (popUpEspera != null) {

         logger.warning("DD It will hide the popUp because the download is done");

           popUpEspera.hide();

            }

            logger.warning("DD It turns off the poll because the download is done");

            poll.setInterval(-1);

            AdfFacesContext.getCurrentInstance().addPartialTarget(poll);

        } // END IT IS DOWNLOAD DONE

    else { // START IT IS STILL DOWNLOADING

    logger.warning("DD IT WILL CLICK THE INVISIBLE LINK FROM THE POLL");

            AdfFacesContext.getCurrentInstance().addPartialTarget(poll);

            RichLink link = (RichLink) JSFUtils.findComponentInRoot("lInv");

            ActionEvent actionEvent = new ActionEvent(link);

            actionEvent.queue();

    logger.warning("IT WORKS");

} /// END IT IS STILL DOWNLOADING

} // END OF THE POLL

Now we have the download file method:   THIS WHERE THE ERROR SHOW

   public void downloadFile(FacesContext facesContext, OutputStream outputStream) throws IOException {

        downloading = true;

        logger.warning("### LINE UNDERNEATH IS THE ONE THAT WILL DOWNLOAD THE DILE FROM THE CLOUD ");

        logger.warning("### IT WORKS WELL  ");

        this.setFileContent(bajarCOSDesdeNube());

        logger.warning("### file content FROM FILE COS: " + fileContent);

        logger.warning("### COS FILE LENGTH: " + fileContent.length);

        try {

            if (fileContent != null && fileContent.length > 0) {

             logger.warning("DD 10_08_2018 BEFORE WRITE");

          // THIS WRITE LINE UNDERNEATH IS WHERE THE ERROR HAPPENS

                outputStream.write(fileContent);

                logger.warning("DD 10_08_2018 AFTER WRITE");

            } // CONTENID

            logger.warning("DD 10_08_2018 BEFORE FLUSH");

            outputStream.flush();

            logger.warning("DD 10_08_2018 AFTER FLUSH");

            downloading = false;

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

I know this happening because of many different request that I am sending to the client or because of the JSF lifecycle.

I would appreciate any help you can give me.

I am working with jdev version 12.2.1.2.0.

Note: this are some things that I already tried.

1.  Work the page as .jspx and .jsf.

2. Show the popup through javascript  (Still throwing the error).

3. Try to click the invisible downloading link through javascript, for some reason in the did not click the link although it found it.

Answers

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,676 Red Diamond
    edited Sep 20, 2018 5:52AM

    Have you tried the sample from the blog as is?

    Does it work without any changes in your jdev version?

    Timo

  • DanielD7777
    DanielD7777 Member Posts: 45
    edited Sep 20, 2018 12:55PM

    Hi , timo I tried as the blog first but with some changes in the pages where I have my fragments.

    The changes that I did are described in the post as:

    1. Instead of call the button by and turn the poll on by javascript. I did it by java.

    It works smoothly in pages with fragments which have the download function inside the fragment

    but in pages  without fragment the error pops up in the page.

    I did it whit this changes because by javascript the poll turning on did not work.

    Note: A change that I saw from the blog is the JDev version.

    From the blog is 11.1.1.7. and mine is 12.2.1.2.0.

  • DanielD7777
    DanielD7777 Member Posts: 45
    edited Sep 20, 2018 12:56PM

    Hi , timo I tried as the blog first but with some changes in the pages where I have my fragments.

    The changes that I did are described in the post as:

    1. Instead of call the button by and turn the poll on by javascript. I did it by java.

    It works smoothly in pages with fragments which have the download function inside the fragment

    but in pages  without fragment the error pops up in the page.

    I did it whit this changes because by javascript the poll turning on did not work.

    Note: A change that I saw from the blog is the JDev version.

    From the blog is 11.1.1.7. and mine is 12.2.1.2.0.

This discussion has been closed.