从以前的论坛和来自互联网的信息中,我发现会话到期时重定向到 login.xhtml 或登录页面的唯一合乎逻辑的解决方案是使用 OmniFaces。
使用omnifaces 后,我可以在会话到期时被定向到login.xhtml。不幸的是,ajax=true
当会话到期时,我无法在 primefaces 上定向到 login.xhtml。我认为问题出在primefaces上。因为,当我使用纯 Jsf 等h:commandButton
时ajax=true
,我可以在会话到期时被定向到 login.xhtml。但是当我使用 primefaces 时它不起作用ajax=true
。您可以在下面更清楚地理解我的意思:
<!-- It can be directed to login.xhtm after session expire -->
<h:commandButton value="throw SQL exception on ajax request"
action="#{kdsHome.openCandidateAtmSelectPanelListener}">
<f:ajax execute="@form" render="@form" />
</h:commandButton>
<!-- It can't be directed to login -->
<p:commandButton value="throw SQL exception on ajax request"
action="#{kdsHome.openCandidateAtmSelectPanelListener}"
update="@form">
</p:commandButton>