0 Replies Latest reply on Jun 16, 2008 7:05 PM by Charles Caron

    ViewHandlerException Problem...

    Charles Caron Newbie

      Hi,


      I'm having some problems with the JSF ViewExpiredException.


      Here's the situation :


      In my application, I allow users to import Excel files. For this, I use the RichFaces Component rich:fileUpload This component is binded to a FileUploadManager class, wich then calls the appropriate business method : ExcelImport.importFile(file).


      Of course, I need to validate the data I read from the excel file, and I also need to throw custom exceptions.


      Here's the fileUploadManager class :



      @Name("fileUploadManager")
      @Scope(ScopeType.PAGE)
      public class FileUploadManager {
      
           public void fileUploadListener(UploadEvent event) throws IOException, BadVersionException {
      
                UploadItem item = event.getUploadItem();
                
                if (item != null) {          
                     
                     File file =  item.getFile();
                     
                     ExcelImport excelImport = new ExcelImport();
                     excelImport.importFile(file);                        
                }
           }
      }
      




      Here's a snippet of my code :



      double versionNumber = version.getRow(20).getCell((short)1).getNumericCellValue();
      if (versionNumber != EstimateHome.ESTIMATE_VERSION)
      throw new BadVersionException(EstimateHome.ESTIMATE_VERSION,versionNumber);
      



      And here's the exception class



      @Redirect(viewId="/error.xhtml",message="Error")
      public class BadVersionException extends Exception {
           
              private static final long serialVersionUID = 1L;
           
           public BadVersionException(double currentEstimateVersion,double attemptedVersion) {
                
                 super("Error");     
      
           }
      }
      



      If I upload a file that should trigger this exception, everything works fine, the exception is fired, but immediately after, a javax.faces.application.ViewExpiredException is thrown. This exception has its own error message defined in pages.xml, and it swallows all the previous exceptions.


      So, the user does not see the message associated with my custom BadVersionException, but the one associated with the ViewExpiredException. Is there any way I can prevent this exception from firing ?


      Environment info :


      JBoss Seam 2.0.2.SP1


      JBoss AS 4.2.2.GA


      Thanks for your help, Charles