- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 OmniFaces FullAjaxExceptionHandler
和 PrimeFaces。我在 errorPage.xhtml
中添加了一个命令按钮,如下所示:
<h:form>
<p:commandButton id="logoutButtonId" value="Redirect" actionListener="#{userMB.logout()}">
</h:form>
错误页面正确显示,但按钮未触发方法 #{userMB.logout()}
。这是我所了解的我的设置中发生的事情:
FullAjaxExceptionHandler
会很好地显示 errorPage.xhtml
。只有在第二次单击时才会调用 bean 方法。似乎在第一次加载时,bean 方法没有绑定(bind)到对象。
在使用 FullAjaxExceptionHandler
时,如何在错误页面中添加一个命令按钮,并将 Action / Action 监听器正确绑定(bind)到 HTML 组件?
最佳答案
这就是对我有用的方法,结合了 BalusC 在他下面的回答中提到的方法。它适用于 IE 和 Firefox。在某些情况下可能需要进行一些调整,但由于我得到的错误页面只有一种形式,所以我没有费心去遍历这些形式。
var originalPrimeFacesAjaxResponseFunction = PrimeFaces.ajax.AjaxResponse;
PrimeFaces.ajax.AjaxResponse = function(responseXML) {
var newViewRoot = $(responseXML.documentElement).find("update[id='javax.faces.ViewRoot']").text();
if (newViewRoot) {
var viewState = $(responseXML.documentElement).find("update[id='javax.faces.ViewState']").text();
$('head').html(newViewRoot.substring(newViewRoot.indexOf("<head>") + 6, newViewRoot.indexOf("</head>")));
$('body').html(newViewRoot.substring(newViewRoot.indexOf("<body>") + 6, newViewRoot.indexOf("</body>")));
if (!$('input').attr("javax.faces.ViewState")){
var hidden = document.createElement("input");
hidden.setAttribute("type", "hidden");
hidden.setAttribute("name", "javax.faces.ViewState");
hidden.setAttribute("value", viewState);
hidden.setAttribute("autocomplete", "off");
$('form').append(hidden);
}
} else {
originalPrimeFacesAjaxResponseFunction.apply(this, arguments);
}
};
关于jsf - 如何调用 p :commandButton in the error page shown by FullAjaxExceptionHandler?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14272835/
我刚刚扩展了 OminFaces 的 FullAjaxExceptionHandler 类,以添加我的项目所需的简单功能。 我所要做的就是简单地使用记录器记录所有异常,并在日志和请求中添加唯一的错误标
所以在面对可怕的javax.faces.application.ViewExpiredException之后,我不得不在互联网上寻找合适的解决方案。幸运的是,这些解决方案随时可用,我继续采用了 Omn
我在使用 Omnifaces FullAjaxExceptionHandler ( http://showcase.omnifaces.org/exceptionhandlers/FullAjaxEx
我正在使用 OmniFaces FullAjaxExceptionHandler显示错误页面。错误页面显示正确,但这些页面的样式有问题。 我的应用程序使用的模板在 body 元素上定义了 CSS 类。
在 OmniFaces 中,FullAjaxExceptionHandler找到要使用的正确错误页面后,调用 JSF 运行时来构建 View 并呈现它,而不是包含 AJAX 调用的页面。 为什么这个?
我已经实现了 Omnifaces FullAjaxExceptionHandler,但问题是它无法处理 ajax 请求。当我单击非 ajax 按钮时 session 过期后,它运行良好。它将用户重定向
我正在使用 OmniFaces FullAjaxExceptionHandler和 PrimeFaces。我在 errorPage.xhtml 中添加了一个命令按钮,如下所示: 错误页面
我正在使用 Omnifaces FullAjaxExceptionHandler - 它工作得很好,但是当我执行一个 ajax 调用并有一个检查状态 == '成功' 的单一事件函数时,它仍然被调用,即
FullAjacExceptionHandler 只能捕获 javax.el.ELException 或 java.lang.Throwable。 Throwable 也优先于 javax.el.
我是一名优秀的程序员,十分优秀!