8 Replies Latest reply on Mar 12, 2013 8:24 PM by Jai Om-Oracle

    <af:fileDownloadActionListener> not calling the bean method

    Jai Om-Oracle

      I am using Jdev
      I have a page where user can generate the report and download it. I am using <af:fileDownloadActionListener> for this on my jsff (implemented as region using BTF).
      The commandbutton with <af:fileDownloadActionListener> is calling a backing bean method. When user clicks the "Print" button, it is supposed to generate the report and allow user to download it.
      The issue here is that the control never goes to bean method after button press. The browser keeps showing busy but no control passed to bean method. Interestingly, after you close the browser, it immediately goes to bean method.
      I have tried waiting for long time (some times 15-20 min) but it never goes there during execution.
      What could be going wrong here?
      Code snippet from my jsff:
      <af:commandButton id="cb1"
                     <af:fileDownloadActionListener method="#{someMethod}"
      This is really frustrating as I have no clue what is going wrong here. The similar code works in other page but not here.
      I would highly appreciate help here.

        • 1. Re: <af:fileDownloadActionListener> not calling the bean method
          Timo Hahn
          Have you tried with partialSumbit="true"?

          • 2. Re: <af:fileDownloadActionListener> not calling the bean method
            Jai Om-Oracle
            Thanks for your response Timo.
            I have tried with af:commandToolbarButton> without setting partialSubmit property and which has default partialSubmit="true".
            Then I read in <af:fileDownloadActionListener> documentation that it forces partialSubmit="false", so I tried with af:commanButton and explicitly setting partialSubmit="false".

            What could be causing this behavior of not going to bean method until you close the browser?

            • 3. Re: <af:fileDownloadActionListener> not calling the bean method
              Timo Hahn
              You have not at the mine type. Set it and see if this helps.

              Otherwise I don't see a reason without trying it out myself which I can do tomorrow.

              • 4. Re: <af:fileDownloadActionListener> not calling the bean method
                Timo Hahn
                I just made a test using and a normal button as well as a toolbar button are working OK.
                                 <af:toolbar id="t1">
                                    <af:commandToolbarButton text="commandToolbarButton 1" id="ctb1">
                                      <af:fileDownloadActionListener filename="yy.txt" method="#{JsServerBean.fileDownload}"/>
                and the bean method
                    public void fileDownload(FacesContext facesContext, OutputStream outputStream) throws UnsupportedEncodingException, IOException {
                        OutputStreamWriter w = new OutputStreamWriter(outputStream, "UTF-8");
                        w.write("Hi there!");
                        // The stream is automatically closed, but since we wrapped it,
                        // we'd better flush our writer
                So it must be something on your side.
                Do other button work on the page?

                • 5. Re: <af:fileDownloadActionListener> not calling the bean method
                  Frank Nimphius-Oracle

                  I would focus on

                  +"This is really frustrating as I have no clue what is going wrong here. The similar code works in other page but not here."+

                  So what is the difference between when this works and when it doesn't?

                  • 6. Re: <af:fileDownloadActionListener> not calling the bean method
                    Jai Om-Oracle
                    Virtually no difference!
                    That's why it is so frustrating that it should work as I don't see anything wrong but it doesn't.
                    This page and where it works are almost exactly same. These are simple pages and I don't see anything that could cause this issue.

                    • 7. Re: <af:fileDownloadActionListener> not calling the bean method
                      Timo Hahn
                      OK, Have you tried to setup a new fresh page (like I did)?

                      Oh, and have you deleted the classes folder from the viewController project to make sure everything gets compiled again?


                      Edited by: Timo Hahn on 12.03.2013 15:35
                      • 8. Re: <af:fileDownloadActionListener> not calling the bean method
                        Jai Om-Oracle
                        Like I said, it is working fine on my other pages and I tried on new page, just like yours, and it worked. It is not working where I need it.
                        I know the issue is somewhere with my page [child or parent, explained later] and I am looking for help on finding the root cause. Some direction/tip which I can follow and figure out the issue.
                        Other buttons are working fine on the page but <af:fileDownloadActionListener> does not work. The page seems to go in loop as it keeps printing generic messages that are generally printed when page is submitted.
                        This will continue until you close the page/browser and then the control goes to bean method.

                        Let me explain page structure:
                        My application is based on UIShell and is basically based one page application. Every page (jsff) is implemented as region using BTF. When user clicks on menu, MainPage is opened. This MainPage represents main structure using layout components like panelGroupLayout, panelTabbed, showDetailItem etc. These layout components contains <af:region> implemented using BTF.
                        The MainPage which has this issue is large page with almost 100+ BTF af:regions implemented under panelTabbed+showDetailItem combination.
                        <af:fileDownloadActionListener> has been implemented on one of the <af:region>, which is part of this MainPage.

                        Few Observations:
                        1. If I move this button [with <af:fileDownloadActionListener>] to any of the af:region under current MainPage then it does not work.
                        2. If I move this button [with <af:fileDownloadActionListener>] to any independent page or any <af:region> which is part of some other MainPage, then it works.
                        3. Other MainPage where it is working fine is also a fairly large page with almost 150+ BTF af:regions
                        4. All our MainPages are based on template, so there is very high level of consistency in behavior and other handlings.

                        For whatever reason, it is not working on my current page and I would highly appreciate any input based on above info [or otherwise] to find a root cause for this issue.
                        If I need to debug, where should I start? What could be causing that looping behavior, specially with <af:fileDownloadActionListener>.