2011-05-12 154 views
0

我使用的是JSF 1.2 + Seam 2.2.1和JBossAS 4.0.4。Seam不捕獲ViewExpiredException

我在文件pages.xml中輸入以下內容:

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

但是,如果我在一個commandLink和一個命令單擊會話過期後,服務器會拋出以下異常:

12:19:09,671 WARN [lifecycle] executePhase(RESTORE_VIEW 1,[email protected]) 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) 

也可能值得注意的是,沒有任何迴應得到任何回報。

我已經試圖明確捕捉異常,但它不起作用。

有什麼建議嗎?

回答

0

我發現這個搜索時錯誤使用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是我們用來寫入當前頁面的一段代碼,但您可以將其重定向到您想要的任何位置。

+0

都能跟得上。沒有什麼我作爲一個exceptio類工程。 – 2011-05-13 12:35:33

0

我發現此鏈接Seam's community site他們在討論類似的問題。也許你的答案在那裏?它們涵蓋了幾種不同的解決方案,具體取決於問題源於何處。

0

嘗試使用在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>