2011-05-12 152 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>