1 Reply Latest reply on Apr 18, 2012 11:30 AM by brabbit27

    Notification when file type rejected RF 4

    brabbit27

      Hallo !

       

         I've been using RichFaces 4 for a while for uploading files to a server. I saw that the rich:fileUpload component has the ability to accept or reject a file depending on the extension of the file.

          To make my webapp more user-friendly I would like to notify the user when a file was rejected. I see there's something like rich:notifyMessage component but I don't know how to make the notification globe appears when a file was rejected. I'm using ontyperejected event but still nothing appears on screen.

          It would be really nice to have a globe that appears and fades out just to give some feedback to the user. So far I have this:

       

          <rich:fileUpload id="fileUploadComp"
                           addLabel
      ="Agregar" clearAllLabel="Quitar todos"
                           clearLabel
      ="Quitar" deleteLabel="Quitar"
                           doneLabel
      ="Completado" uploadLabel="Subir archivos"
                           fileUploadListener
      ="#{uploadBean.doUpload}"
                           acceptedTypes
      ="txt, csv" onclear="onclear(event);"
                           noDuplicate
      ="true">
             
      <a4j:ajax event="uploadcomplete" render="validationButton"/>
             
      <a4j:ajax event="typerejected" render="notificationFileRejected"/>
         
      </rich:fileUpload>

         
      <rich:notifyMessage for="fileUploadComp"
                              id
      ="notificationFileRejected"
                              sticky
      ="true"
                              ajaxRendered
      ="true"
                              title
      ="Hello"/>

       

      Any idea on how can I make this message appear?

       

      Cheers

        • 1. Re: Notification when file type rejected RF 4
          brabbit27

          Well finally I found a solution.

           

          <rich:fileUpload id="fileUploadComp"
                           addLabel
          ="Agregar" clearAllLabel="Quitar todos"
                           clearLabel
          ="Quitar" deleteLabel="Quitar"
                           doneLabel
          ="Completado" uploadLabel="Subir archivos"
                           fileUploadListener
          ="#{uploadBean.doUpload}"
                           acceptedTypes
          ="txt, csv" onclear="onclear(event);"
                           ontyperejected
          ="ontyperejected();"
                           noDuplicate
          ="true">
             
          <a4j:ajax event="uploadcomplete" render="validationButton"/>
          </rich:fileUpload>

          <a4j:jsFunction name="ontyperejected" actionListener="#{uploadBean.setMessage()}"/>

          <rich:notifyMessage stayTime="2000" nonblocking="true"/>

           

          with the backing bean

           

          public void setMessage() {
           
          String message="Wrong filetype...";
           
          FacesContext.getCurrentInstance().addMessage("info", new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));
          }

           

          The only little problem I found in this is that If the user select the same file consecutively the message doesn't appear the second time. This is, select fileA.wrongType -> notification appears -> Select fileA.wrontType -> NO notification