3 Replies Latest reply on Mar 6, 2013 7:14 AM by vanna mount

    How to get filename when clear event fired

    Federico Martinez Newbie

      Hi all,

       

         I'm developping with JSF 2.1.6 Mojarra and RichFaces 4.1.0 Final. When a user uploads many files and then click on CLEAR ALL button I'm able to delete the files, but if the user clicks on CLEAR link (next to a certain file) how can I get the file's name of the cleared object?

       

         I've read this and this thread but I don't manage to make it work. I'm not so experienced with this web-development stuff.

       

         Here's what I have

       

                          <rich:fileUpload addLabel="Agregar" clearAllLabel="Quitar todos"
                                           clearLabel="Quitar" deleteLabel="Quitar"
                                           doneLabel="Completado" uploadLabel="Subir archivos"
                                           fileUploadListener="#{uploadBean.doUpload}"
                                           acceptedTypes="txt, csv"
                                           onclear="clearFunc(event.memo.entry.fileName);"
                                           noDuplicate="true">
                              <a4j:ajax event="uploadcomplete" render="validationButton"/>
                          </rich:fileUpload>
      
      
                          <a4j:jsFunction name="clearFunc" render="validationButton"
                                          actionListener="#{uploadBean.doClearFile}" >
                              <a4j:param name="filename"/>
                          </a4j:jsFunction>
      

       

      and the backing bean being

       

          public void doClearAllFiles(){
              files.clear();
              validationButtonRendered = false;
          }
      
          public void doClearFile(){
              //How to get file's deleted name???
              files.remove(filename);
              validationButtonRendered = false;
          }
      

       

      Basically I want to execute doClearAllFiles if ClearAll clicked otherwise doClearFile if Clear link next to a file is clicked (deleting just that file).