5 Replies Latest reply on Apr 18, 2008 3:59 PM by Yurii Kartsev

    onuploadcomplete - doesn't fire (waits for ages)

    Yurii Kartsev Apprentice

      Good afternoon, dear RF developers.

      Still getting into new component - rich:fileUpload. I've used your example from the RF Demo (except the mediaOutput):

      <rich:modalPanel id="ajaxLoadingModalBox" minHeight="100" minWidth="350" height="100" width="250" zindex="2000">
       <f:facet name="header">
       <h:outputText value="Request being processed"/>
       </f:facet>
       <rich:spacer height="33px;"/>
       <rich:spacer width="45px;"/><h:outputText value="Your request is being processed, please wait..."/>
      </rich:modalPanel>
      
      ...
      
      <h:panelGrid columns="2" columnClasses="fileupload_top,fileupload_top">
      
       <rich:fileUpload fileUploadListener="#{fuMan.listener}"
       id="upload"
       onupload="Event.stop(event||window.event);"
       uploadData="#{fuMan.fileList}"
       maxFilesQuantity="#{fuMan.maxFiles}"
       immediateUpload="#{fuMan.autoUpload}"
       autoclear="#{fuMan.autoClear}"
       acceptedTypes="#{fuMan.fileTypes}"
       listHeight="#{fuMan.height}" listWidth="#{fuMan.width}">
      
       <a4j:support event="onuploadcomplete" reRender="info" />
      
       <f:facet name="label">
       <h:outputText value="{_KB}KB from {KB}KB uploaded --- {mm}:{ss}" />
       </f:facet>
      
       </rich:fileUpload>
      
       <h:panelGroup>
       <a4j:outputPanel id="info">
      
       <h:outputText value="#{fuMan.fileListSize}"/>
      
       </a4j:outputPanel>
       </h:panelGroup>
      
      </h:panelGrid>


      As you see, I have a modal panel appearing on every ajax request(thanks to your knowledge base). And with this "onuploadcomplete" event this panel is showed forever and info isn't reRendered. BUT if only I change "onuploadcomplete" event to for example "onsizerejected" event and trying to select big sized file - everything goes just perfect: the panel shows till fileUpload says that the size was rejected and then disappears.

      Please, help me to understand what I'm doing wrong?

      And the second question, if you don't mind: is there any event like "onuploadstarted"? I just need to call "Event.stop(event||window.event);" to prevent of showing of the modal panel and can't make it before upload starts(even if i use "onupload" event). Help me please.

      Thank you in advance!

      Env: RF 3.2.0, JSF 1.2 + Facelets.

        • 1. Re: onuploadcomplete - doesn't fire (waits for ages)
          Yurii Kartsev Apprentice

          I've used firebug to look at the requests. The situation is on the screenshot below.

          On the screenshot:

          1. closed requests(with +) - are just the same as the one which comes second from the top(ends with "......employeePhotoTab_editForm%3Aj_id313&")
          2. JScript errors at the bottom are repeated few times.

          Here is my screenshot:

          http://www.imagehosting.com/out.php/i1701644_firebug.jpg

          I really hope that it will help.

          Waiting for help... :( Thank you in advance.

          • 2. Re: onuploadcomplete - doesn't fire (waits for ages)
            Andrei Markavtsov Apprentice

            J-Pro,

            Your example is uncomleted, so I can only assume how you show modal panel after ajax request started...

            I think you use <a4j:status> component, in 'onstart' & 'onstop' attributes you show and hide panel by JS API.

            Am I right?

            As I understand you want to show panel until uploading will be completed.

            The code above is not a correct way to do it.
            Because:
            1. Upload request is not ajax
            2. There are many another ajax requests during file uploading (from progresBar for example)

            The correct way:
            Call show() method after upload started. (Use onuploadstart event. It will be implemented in a moment. Look at http://jira.jboss.com/jira/browse/RF-3119 )
            Call hide() method after upload completed. (Use onuploadcomplete event).


            Please let me know if I wrote something uncleared or if I understand you incorrectly.

            • 3. Re: onuploadcomplete - doesn't fire (waits for ages)
              Yurii Kartsev Apprentice

               

              "andrei_exadel" wrote:
              J-Pro, Your example is uncomleted, so I can only assume how you show modal panel after ajax request started...

              I think you use <a4j:status> component, in 'onstart' & 'onstop' attributes you show and hide panel by JS API.

              Am I right?

              Yes, you're absolutely right. Sorry, I've just forgot to give this piece of code:
              <a4j:status onstart="Richfaces.showModalPanel('ajaxLoadingModalBox',{width:350, top:200})"
               onstop="Richfaces.hideModalPanel('ajaxLoadingModalBox')"/>

              "andrei_exadel" wrote:
              As I understand you want to show panel until uploading will be completed.

              No, actually vice versa: I want this panel to NOT show while uploading is in progress(to make user able to cancel it of he wants to), but show it while other ajax stuff is processing. That's why I have "onupload="Event.stop(event||window.event);"" in my fileUpload control. But as you said that "onuploadstart" is on the way - so I should use it this way to prevent modal panel from appearing while uploading: "onuploadstart="Event.stop(event||window.event);"", am I right?


              And the question about the SUBJ: I've noticed that my modal panel disappears and appears again, only then it stucks. So I assume that it's reRendering problem. reRender - it's AJAX stuff(so the panel is showed). And as you can see on the screenshot - the digit "0" and mediaOutput were not rendered while file upload is finished. That's why my modal panel still holds on the screen(I waited almost for 30 minutes - it still holds on). That's the problem I've created the post. Are there any solutions to properly reRender needed controls and finish AJAX request(to let modal panel disappear)?

              • 4. Re: onuploadcomplete - doesn't fire (waits for ages)
                Andrei Markavtsov Apprentice

                OK, I understood.

                You want to disable showing modalPanel for file uploading process.

                But 'Event.stop(event||window.event);' is stopping current event.
                It has no effect in this case.

                I think the next solution can be applied: use 'status' attribute of component. You can define there non-existent status id. So ajax will process without component status switching.

                But one problem: progressBar has status attribute, but fileUpload does not.

                At the first try define "progress" facet inside the fileUpload and put there progressBar with 'status' attribute defined.

                If you like this solution we can add 'status' attribute to fileUpload.

                • 5. Re: onuploadcomplete - doesn't fire (waits for ages)
                  Yurii Kartsev Apprentice

                  Dear Andrei, thanks again for your answers. I really appreciate it.

                  Sorry for bothering, but what do you thing about the main question for me: "question about the SUBJ" at the bottom of my last post? Can you help me with that? It's really important.

                  use 'status' attribute of component. You can define there non-existent status id. So ajax will process without component status switching.

                  Maybe it's my week point here, because I don't understand it's sense. But still I've made some experiments with rich:progressBar and added "status=2344243" there - which helped me to prevent modal panel appearance. And it really would be nice to have such attribute in fileUpload(but since you said that fileUpload has many ajax requests, are you sure, that it helps? If yes - sure, it would be nice to have it there!).

                  And one more thing: would you please point me to any resource(in internet) where I can get into "status" attribute? (I saw the TLD, but "ID (in format of call UIComponent.findComponent()) of Request status component" doesn't tell me much). Because I really don't understand why if I specify unknown status, modalPanel isn't showing, but progress bar works properly. And in case of for example a4j:commandButton - this way is a wrong one, because if I specify such status - modal panel isn't showing, BUT commandButton doesn't work at all. Thanks for your answer, I really want to get into that!

                  Thanks again for your time, Andrei.