2 Replies Latest reply on Jun 1, 2010 10:02 PM by mwengren

    Seam exception handling: error redirecting to facesContext.viewRoot.viewId

      This post: http://seamframework.org/Community/AnyWayToKnowWhatIsTheCurrentViewid says that when configuring exception handling via pages.xml, instead of specifying a redirect to a predefined error view, you can specify that the redirect goes to the current view ID.  This is the code to use from the post


      #{facesContext.viewRoot.viewId}



      so you have:


      <exception class="...."><redirect view-id="#{facesContext.viewRoot.viewId}"></exception>




      When I tested this with Seam 2.1.1.GA, it evaluates to an empty string, so that the redirect goes to my webapp root instead of the current view id.  However, if I embed the same EL expression within the message element, it correctly outputs the current viewId value inside the error message:



      <exception class="....">
          <redirect view-id="/error.xhtml">
          <message>viewID: #{facesContext.viewRoot.viewId}</message>
       </exception>



      the resulting error message displayed on /error.xhtml contains:


      viewID: /new.xhtml



      I got around this issue by redirecting to the following EL, which is equivalent to the viewID (my app has a prefix-mapped Faces Servlet):


      <exception class="....">
         <redirect view-id="#{facesContext.externalContext.requestServletPath}#{facesContext.externalContext.requestPathInfo}">
      </exception>




      But I was curious as to why the facesContext.viewRoot.viewId EL expression was correct inside the error message but was returned an empty string inside the redirect element.  Anyone else observed this?



      Thanks!