Шов не захватывает исключение ViewExpiredException - PullRequest
0 голосов
/ 12 мая 2011

Я использую JSF 1.2 + Seam 2.2.1 и JBossAS 4.0.4.

У меня есть следующая запись в файле pages.xml:

<exception>
    <end-conversation/>
    <redirect view-id="/facelets/error.xhtml"/>
</exception>

Но если я нажимаю на commandLink и commandButton после истечения сеанса, сервер выдает следующее исключение:

12:19:09,671 WARN  [lifecycle] executePhase(RESTORE_VIEW 1,com.sun.faces.context.FacesContextImpl@1d7187f) threw exception
javax.faces.application.ViewExpiredException: viewId:/facelets/login.xhtml - View /facelets/login.xhtml could not be restored.
  at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:187)

Также стоит отметить, что никакой ответ не возвращается вообще.

Я уже пытался явно перехватить ловушку исключения, но оно не работает.

Есть предложения?

Ответы [ 3 ]

0 голосов
/ 13 мая 2011

Я нашел эту ссылку на сайте сообщества Seam , где обсуждается аналогичная проблема. Возможно, ваш ответ там? Они охватывают несколько различных решений, в зависимости от того, откуда возникла проблема.

0 голосов
/ 21 июля 2011

Попробуйте использовать в файле pages.xml следующее:

<exception class="javax.faces.application.ViewExpiredException">
    <redirect view-id="/pages/login.xhtml">
        <message severity="error">Your session has timed out, please Log-In again</message>
    </redirect>
</exception>
0 голосов
/ 12 мая 2011

Я нашел это при поиске обработки ошибок в Seam некоторое время назад

    <\!-\- Now we specify the super class of all Exceptions: java.lang.Exception.  This will catch all exceptions. \-->
    <\!-\- But it will give us access to the Exception to retrieve its contents for display to the screen.         \--> 
  <exception class="java.lang.Exception">
      <\!-\- still a good idea to end the "conversation" rather than leaving it open ended. \-->
      <end-conversation/>
        <\!-\- now we redirect to the current page. The code for this is in the next example. \-->
      <redirect view-id="#{viewId.currentValue}">
        <\!-\- specify the message severity as error.  Also the expression language used below allows us to "grab"-->      
        <\!-\- the exception that was captured above and then pass it to the h:message tag for display to the end \-->    
        <\!-\- user.  Much nicer than a debug screen.                                                             \-->     
        <message severity="error">
          #{org.jboss.seam.handledException.message}
        </message>
      </redirect>
  </exception>

С этим вы действительно сможете поймать все и разоблачить, что это такое. viewId.currentValue - это фрагмент кода, который мы использовали для записи на текущую страницу, но вы можете перенаправить туда, куда хотите.

...