8 Replies Latest reply on Apr 4, 2011 9:14 AM by ilya_shaikovsky

    FileUpload and "onuploadcomplete" reRender

    ccaspanello

      Hey guys,

       

      This is my first post on the RichFaces forum.  From what I've seen this is a great community and it has been a source for most solutions to my issues.  However, I have come across something that is unusual and figured I'd ask here.

       

      We are currently using the File Upload widget and I am unable to rerender an element after the upload is complete.  My JSP is similar to the demo.

       

            <h:panelGroup id="uploadWidgetWrapper">

                  <rich:fileUpload id="fileAttachment_dataTable" fileUploadListener="#{fileUploadBean.listener}" maxFilesQuantity=5">
                      <a4j:support event="onuploadcomplete" reRender="uploadWidgetWrapper" />
                  </rich:fileUpload>

                  <rich:dataTable id="fileAttachment_dataTable">

                       >> 2 Columns - File Download Link and Remove Link  <<

                  </rich:dataTable>

            </h:panelGroup>

       

          public void listener(UploadEvent event) throws Exception

          {
              // Stuff that works

          } 

      Now, I would like to point out a few things.

        - In my "remove file link" I reRender the "uploadWidgetWrapper" and it works fine

        - When I click the upload button everything in the UploadEvent listener works fine; however, the little swirly icon in the internet explorer tab keeps spinning (as if the page was still loading).  This to me seems like an AJAX reponse is still running behind the scense.

        - If I purposely misspell the reRender attribut from "uploadWidgetWrapper" to "aslkdjfasldfj" I get an error in my log.  This let's me know that the framework is recognizing the "onuploadcomplete" action and is trying to rerender.

       

      Any Ideas?  This one has me stumped.

       

      Thanks in advanced for your help,

      Chris


        • 1. Re: FileUpload and "onuploadcomplete" reRender
          ilya_shaikovsky

          1) check last request execution in a4j:log for errors

          2) about the loading icon. Actually auplaods by Ajax not possible because of security restrictions. So actually it occurs because we simulates assynchronous requests using submit in iframe. B.t.w. if Flash is not prohibited for usage in your applications - turn it on. There should be no such effect if upload handled by Flash.

          • 2. Re: FileUpload and "onuploadcomplete" reRender
            ccaspanello

            Hey Ilya,

             

            Tthanks for the reply and education.  Come to find out my element was actually being rerendered; it just wasn't getting refreshed with the latest and greatest from the bean.  Some java code fixed this.

             

            Thanks again,

            Chris

            • 3. Re: FileUpload and "onuploadcomplete" reRender
              desivanova

              Hi Chris

               

              I'm facing the same problem and can't find what is the problem with the  components to do not be rerenderd after uploadcomplete. I tried to put the  components that need to be refreshed in different tags(outputpanels, tables .. etc)  and the problem remains .... If I refresh the page F5 all the components are refreshed as expected.

              Please place some code here or explain what was wrong with your code.

               

              Thanks in advance!

              Desi

              • 4. Re: FileUpload and "onuploadcomplete" reRender
                ilya_shaikovsky

                I'm not sure that Cris monitoring that thread as he solved his problem about a year ago

                 

                So please post your code and we will check for the problems there.

                • 5. Re: FileUpload and "onuploadcomplete" reRender
                  desivanova

                  Seems that the problem exist with jsf 2, because when I downgraded to 1.2 (jboss5 is delivered with jsf1.2 in) the control works perfectlly.

                  The code is:

                   

                  <rich:fileUpload

                                      fileUploadListener="#{fileUploadBean.listener}"

                                      maxFilesQuantity="1" id="fileUploadId"

                                      immediateUpload="true"

                                      acceptedTypes="txt"

                                      allowFlash="true" >            

                                      <a4j:support event="onuploadcomplete" reRender="scdocid" />

                                       <a4j:support event="onclear" reRender="fileUploadId,scdocid" action="#{fileUploadBean.clearUploadData}"/>                   

                                  </rich:fileUpload>

                                  <h:panelGroup id="scdocid">           

                                         <table id="scftbl" class="infotbl" cellpadding="0" cellspacing="0">

                                           <!-- information for file path just uploaded + number rows detected - file is plain text  ->>

                                           </table>

                                     </h:panelGroup>

                  • 6. Re: FileUpload and "onuploadcomplete" reRender
                    ilya_shaikovsky

                    Please check a4j:log information about that last request.

                     

                    P.S. if you moving to JSF 2 why not to try RF 4 ?

                    • 7. Re: FileUpload and "onuploadcomplete" reRender
                      desivanova

                      Thanks for responce

                       

                      I checked log and there is a warning:

                      warn[14:36:18,523]: Node for replace by response with id mForm:j_id51:j_id234 not found in document

                       

                      the form <h:form id="mForm"> encloses all components rich:fileUpload and results after uploading.

                       

                      For now I use a workaround to refresh page with button 'Apply ..' button

                      But will be nice if you have idea about file upload and put it in modal panel. My initial desing was to show a button 'load file' and on this to attach modal panel where to put rich:fileupload. Unfortunatelly if I use this approach the listener is not fired at all. Can you give me a hint about this implementation.

                      here is a code:

                      <rich:modalPanel id="loadDocsPanel" autosized="true">

                                  <f:facet name="header">

                                      <h:outputText value="#{msg.UI_LOAD_DOC_FROM_FILE}" />

                                  </f:facet>

                                  <f:facet name="controls">

                                      <h:graphicImage value="/images/buttons/bclose.gif"

                                          onclick="Richfaces.hideModalPanel('loadDocsPanel')" />

                                  </f:facet>

                                    <a4j:form id="uploaderform">

                                  <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"

                                      maxFilesQuantity="1" id="upload"

                                      immediateUpload="#{fileUploadBean.autoUpload}"

                                      acceptedTypes="#{fileUploadBean.acceptedTypes}"

                                      allowFlash="#{fileUploadBean.useFlash}">        

                                      <a4j:support event="onuploadcomplete" reRender="scInfo"

                                          oncomplete="Richfaces.hideModalPanel('loadDocsPanel')" />

                                  </rich:fileUpload>

                                  </a4j:form>

                              </rich:modalPanel>

                             

                              <a4j:commandButton id="selectFile"

                                  value="#{msg.UI_LOAD_DOC_FROM_FILE }" ajaxSingle="true">

                                  <rich:toolTip showEvent="onmouseover" direction="bottom-left"

                                      value="#{msg.MSG_FILEUPLOAD_FORMAT}">

                                  </rich:toolTip>

                                  <rich:componentControl for="loadDocsPanel" attachTo="selectFile"

                                      operation="show" event="onclick" />

                              </a4j:commandButton>

                       

                      <h:panelGroup id="scInfo">           

                                             <table id="scftbl" class="infotbl" cellpadding="0" cellspacing="0">

                                               <!-- information for file path just uploaded + number rows detected - file is plain text  ->>

                                               </table>

                                         </h:panelGroup>

                       

                       

                      Is it possible at all to make it work

                       

                      Desi

                      • 8. Re: FileUpload and "onuploadcomplete" reRender
                        ilya_shaikovsky

                        you sure that the modal panel not lying in any external forms?