4 Replies Latest reply on Aug 2, 2012 1:15 PM by Mahesh Pal

    <rich:fileupload> rerendering problem

    Mahesh Pal Newbie

      Hi All.

      I am creating jsf+richfaces applicationi i want to  print some message wen file uploading is done bur its not working.Rerender attribute is not working here. i am posting my code here i have removed all un necessary code for simplicity.

      upload.xhtml

      ************************

       

       

      <head></head>

      <body>

          <h:form enctype="multipart/form-data">

       

          <rich:fileUpload  allowFlash="true" fileUploadListener="#{uploadMB.listener}" uploadData="#{uploadMb.files}"  >

       

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

       

          </rich:fileUpload>

       

         <h:outputText value="#{uploadMB.msg}" id="info" />

          </h:form>

       

       

       

      </body>

      </html>

      ********************************

       

       

      public class UploadMB {

       

          List<File> files=new ArrayList<File>();

       

          String msg;

       

       

          public String getMsg() {

              return msg;

          }

       

       

          public void setMsg(String msg) {

              this.msg = msg;

          }

       

       

       

       

       

       

          public List<File> getFiles() {

              return files;

          }

       

       

          public void setFiles(List<File> files) {

              this.files = files;

          }

       

       

          public void listener(UploadEvent ue){

       

       

              System.out.println("uploaded");

       

              msg="Success";

       

       

       

       

          }

       

      }

      *****************************************

      after the file get uploaded its not printing my msg.

        • 1. Re: <rich:fileupload> rerendering problem
          nguyen tung son Newbie

          Don't need reRender message, rich:fileUpload support checking file size, file type, upload successful. You can see example code:

          <rich:fileUpload id="uploadDoc1" style="width:100%;border:none;height:100%"

                                       onuploadcomplete="self.parent.location.href='#{uploadController.time}'"

                                       acceptedTypes="#{uploadController.type}"

                                       uploadControlLabel="Upload"

                                       addControlLabel="Chọn file"

                                       clearAllControlLabel="Xóa hết"

                                       clearControlLabel="Xóa"

                                       cancelEntryControlLabel="Hủy"

                                       doneLabel=""

                                       sizeErrorLabel="Kích thước file không phù hợp."

                                       transferErrorLabel="Lỗi xảy ra trong quá trình upload"

                                       progressLabel="Uploading ..."

                                       maxFilesQuantity="10"

                                       fileUploadListener="#{uploadController.uploadDocListener}"

                                       listHeight="108px"

                                       allowFlash="true"

                                       uploadListClass="uploadListClass">

           

                          <f:facet name="label">

                              <h:outputText value="Đã tải lên {_KB}KB từ {KB}KB --- {mm}:{ss}"></h:outputText>

                          </f:facet>

          </rich:fileUpload>

          • 2. Re: <rich:fileupload> rerendering problem
            Mahesh Pal Newbie

            acctually i hv to read file and save data to database.i m doing some validation on data and if validation is failed i hv to show that data to user.i m returning that data in a form of list on the page .for that i need to use this <a4j:support> component.

            • 3. Re: <rich:fileupload> rerendering problem
              nguyen tung son Newbie

              I have idea can help you..

               

              You can't save message in session... then on onuploadcomplete event (<rich:fileUpload)... You use jquery to display message for user

              example....

               

              <div class="infor"></div>

               

              javascript....

               

              $.post("message.jsp",function(data){

              if(data!=null) {

                         $('.info').html(data);

              });

               

              in message.jsp file you can display session message...

               

              Regards

              • 4. Re: <rich:fileupload> rerendering problem
                Mahesh Pal Newbie

                thanks nguyen. it got it.its working now..