如果用户会话因会话超时而过期,我想显示一个对话框,通知它。在此对话框中,按钮将指向登录页面。 我正在使用primefaces 5.1.17和ajaxExceptionHandler,我认为这应该是可能的。但它不起作用。这里有一些代码:
主布局中的xthml:
<h:form id="sessionExpiredDialogForm">
<p:ajaxExceptionHandler type="javax.faces.application.ViewExpiredException" update="sessionExpiredDialogId" onexception="PF('sessionExpiredDialogVar').show();" />
<p:dialog id="sessionExpiredDialogId" widgetVar="sessionExpiredDialogVar" modal="true" closable="false" resizable="false">
<h:panelGrid columns="1" style="width: 100%;">
<h:outputText value="#{msgs['jsftoolkit.errorpage.expired.summary']}" />
</h:panelGrid>
<f:facet name="footer">
<h:panelGrid style="width: 100%;" columnClasses="centerAligned">
<p:commandButton value="#{msgs['jsftoolkit.errorpage.expired.summary.button.ok']}" action="#{logoutController.logout}" ajax="false" style="text-align: center !important;" />
</h:panelGrid>
</f:facet>
</p:dialog>
在web.xml中添加了错误页面:
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/icarchive/views/errorpages/500.xhtml</location>
</error-page>
在faces-config.xml中添加了el-resolver org.primefaces.application.exceptionhandler.PrimeExceptionHandlerELResolver
和org.primefaces.application.exceptionhandler.PrimeExceptionHandlerFactory
。
会话过期后,如果没有对话框或错误消息,ui就不会再做出反应。
由于 奥利弗