5 Replies Latest reply on Nov 23, 2009 1:18 PM by Brandon Harper

    fileUpload problem - error message is not displayed

    Hrvoje Jo Newbie


      I would like to know is there a way to stop fileUploadListener (fileUpload component) and diplay error message?

      I would like to upload file only if file with sam name doesn't egsist on server. It would be nice if the validation would be on client side. So I tried to do validation inside of fileUploadListener, but the message (<h:messages />) is not shown, although the upload is stopped, and message is added.

      Here is the code

      public void processUpload(UploadEvent event) {
       UploadItem item = event.getUploadItem();
       java.io.File f = item.getFile();
       fileList = getFiles();
       for (File file : fileList) {
       FacesContext ctx = FacesContext.getCurrentInstance();
       //Show message
       ctx.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
       "error", "error"));
       //If file doesn't egsists...