1 Reply Latest reply on Mar 24, 2009 11:38 PM by Norman Richards

    exception handling in pages.xml

    Arbi Sookazian Master

      The following is create by seam-gen:


      <?xml version="1.0" encoding="UTF-8"?>
      <pages xmlns="http://jboss.com/products/seam/pages"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd"
      
             no-conversation-view-id="/home.xhtml"
             login-view-id="/login.xhtml">
      
          <page view-id="*">
              <navigation>
                  <rule if-outcome="home">
                      <redirect view-id="/home.xhtml"/>
                  </rule>
              </navigation>
          </page> 
      
          <exception class="org.jboss.seam.framework.EntityNotFoundException">
              <redirect view-id="/error.xhtml">
                  <message>Not found</message>
              </redirect>
          </exception>
          
          <exception class="javax.persistence.EntityNotFoundException">
              <redirect view-id="/error.xhtml">
                  <message>Not found</message>
              </redirect>
          </exception>
          
          <exception class="javax.persistence.OptimisticLockException">
              <end-conversation/>
              <redirect view-id="/error.xhtml">
                  <message>Another user changed the same data, please try again</message>
              </redirect>
          </exception>
          
          <exception class="org.jboss.seam.security.AuthorizationException">
              <redirect view-id="/error.xhtml">
                  <message>You don't have permission to do this</message>
              </redirect>
          </exception>
          
          <exception class="org.jboss.seam.security.NotLoggedInException">
              <redirect view-id="/login.xhtml">
                  <message>Please log in first</message>
              </redirect>
          </exception>
          
          <exception class="javax.faces.application.ViewExpiredException">
              <redirect view-id="/error.xhtml">
                  <message>Your session has timed out, please try again</message>
              </redirect>
          </exception>
           
          <exception>
              <redirect view-id="/error.xhtml">
                  <message>Unexpected error, please try again</message>
              </redirect>
          </exception>
          
      </pages>



      Note that the exception tag in the last block:


          <exception>
              <redirect view-id="/error.xhtml">
                  <message>Unexpected error, please try again</message>
              </redirect>
          </exception>
      


      does not a class attribute.  Is this the final catch all config for any exceptions other than the ones that are configured above it?  Is it roughly equivalent to the following?


      <exception class="java.lang.RuntimeException">
          <redirect view-id="/generalError.xhtml">
            <message>Unexpected failure</message>
          </redirect>
        </exception>



      What if you put the last block at the beginning of the exception block set?  Does it matter what order it shows up in the pages.xml?