Jsf FullAjaxExceptionHandler-找出导致ViewExpiredException的组件?

Jsf FullAjaxExceptionHandler-找出导致ViewExpiredException的组件?,jsf,omnifaces,Jsf,Omnifaces,在使用AJAX时,是否可以判断单击了哪个组件导致抛出了ViewExpiredException?如果用户只是尝试注销,我希望避免显示会话过期页面,而是显示正常的注销页面 我正在考虑覆盖shouldHandleExceptionRootCause,但是我找不到任何东西来确定是否按下了注销按钮 我使用的是MojarraJSF2.2和OmniFaces2.5.1 解决方案 @Override protected boolean shouldHandleExceptionRootCause(Faces

在使用AJAX时,是否可以判断单击了哪个组件导致抛出了
ViewExpiredException
?如果用户只是尝试注销,我希望避免显示会话过期页面,而是显示正常的注销页面

我正在考虑覆盖shouldHandleExceptionRootCause,但是我找不到任何东西来确定是否按下了注销按钮

我使用的是MojarraJSF2.2和OmniFaces2.5.1


解决方案

@Override
protected boolean shouldHandleExceptionRootCause(FacesContext context, Throwable exception)
{
    UIComponent source = Components.getCurrentActionSource();
    if (source != null && "logout".equals(source.getId()))
    {
        NavigationHandler nh = context.getApplication().getNavigationHandler();
        nh.handleNavigation(context, null, "logout.xhtml?faces-redirect=true");
        return false;
    }
    else
    {
        return super.shouldHandleExceptionRootCause(context, exception);
    }
}
实用程序类提供了几种方法来标识当前提交的表单、当前调用的命令和操作事件的源组件(可以是命令组件本身,但在ajax事件中也是输入组件)


你挑吧。例如,您可以检查表单、命令或源代码的
id
,看看它是否是所需的。

正是我想要的,再次感谢您!我是否需要使用类似于
OmniPartialViewContext.getCurrentInstance(context.closePartialResponse()
导航到注销页面后?如果在呈现响应过程中引发异常并且已经编写了部分ajax响应,则仅调用
resetPartialResponse()
。通常情况下,
ViewExpiredException
的情况并非如此。
UIForm form = Components.getCurrentForm();
UICommand command = Components.getCurrentCommand();
UIComponent source = Components.getCurrentActionSource();