3 Replies Latest reply on Sep 17, 2010 3:02 AM by lachlan hendy

    fileupload reRender

    Juan Martin Chiaradia Newbie

      Hello,


      I have a fileupload field and I want to show it only if the file is not uploaded yet.
      For the upload I have used rich:fileUpload with an uploadListener method for attach the upload data to my attachedCopy property.


      The upload is working ok, I can upload any file and when I save the entity, the upload data is saved too, but I have the problem that the reRendering is not working well (or at least as I think it should work).


      Here is the xhtml component:


      <s:decorate id="attachedCopyField" template="/layout/edit.xhtml">
           <ui:define name="label">Adjunto</ui:define>
           <rich:fileUpload id="notaAdjunta"
                rendered="#{outNoteHome.instance.attachedCopy == null}"
                fileUploadListener="#{outNoteHome.processUpload}"
                immediateUpload="true" ajaxSingle="true"
                reRender="attachedCopyField">
           </rich:fileUpload>
           <s:button value="Download"
                rendered="#{outNoteHome.instance.attachedCopy != null}"
                action="#{fileDownloadBean.downloadFile(outNoteHome.instance.attachedCopy)}" />
      </s:decorate>



      Here is the processUpload method:



      public void processUpload(UploadEvent event) {
           File attachedCopy = FileUpload.processUpload(event);
           this.getInstance().setAttachedCopy(attachedCopy);
      }



      after upload is complete, the fileUpload component should disappear and download button shoudl appear, but it is not happening.


      Any tip?


      Regards,
      Chiara

        • 1. Re: fileupload reRender
          Michael Wohlfart Expert

          I didn't try but maybe this works:


          <s:decorate id="attachedCopyField" template="/layout/edit.xhtml">
               <ui:define name="label">Adjunto</ui:define>
               <rich:fileUpload id="notaAdjunta"
                    rendered="#{outNoteHome.instance.attachedCopy == null}"
                    fileUploadListener="#{outNoteHome.processUpload}"
                    immediateUpload="true" ajaxSingle="true">
                    <a4j:support event="onuploadcomplete"
                             reRender="attachedCopyField" />
               </rich:fileUpload>
               <s:button value="Download"
                    rendered="#{outNoteHome.instance.attachedCopy != null}"
                    action="#{fileDownloadBean.downloadFile(outNoteHome.instance.attachedCopy)}" />
          </s:decorate>



          • 2. Re: fileupload reRender
            Juan Martin Chiaradia Newbie

            Hi Michael, thanks for the tip, I already try this but still doesn't work ...


            I will try something else, but I don't know what could be happening.

            • 3. Re: fileupload reRender
              lachlan hendy Newbie

              I have the same problem using Seam 2.1 and richfaces 3.3.3


              using a a4j:support as suggested by Michael didnt work. is there any other solution??