小编fai*_*alb的帖子

Primefaces ExceptionHandler在展示中不起作用

我在primefaces中尝试了新的ExceptionHandler标记,但似乎我遗漏了这个标记的东西.

基本上我的代码与http://www.primefaces.org/showcase/ui/misc/exceptionHandler.xhtml中的相同,问题是添加此标记不会改变任何我在客户端没有得到任何东西的东西.标准的js API无法使用素数按钮:

jsf.ajax.addOnError(function(data) {alert('Error');})
Run Code Online (Sandbox Code Playgroud)

我在运行的应用程序和Primefaces展示之间注意到的唯一区别是我得到的ajax响应与showcase的不同:

我的回复:

在此输入图像描述

陈列柜的回应

在此输入图像描述

这是代码

<h:form>
<h3 style="margin-top:0">AJAX</h3>
<p:commandButton actionListener="#{exceptionHandlerView.throwViewExpiredException}"
                 ajax="true"
                 value="Throw ViewExpiredException!" />
<p:commandButton actionListener="#{exceptionHandlerView.throwNullPointerException}"
                 ajax="true"
                 value="Throw NullPointerException!" />
<p:commandButton actionListener="#{exceptionHandlerView.throwWrappedIllegalStateException}"
                 ajax="true"
                 value="Throw IllegalStateException!" />

<h3>Non-AJAX</h3>
<p:commandButton actionListener="#{exceptionHandlerView.throwViewExpiredException}"
                 ajax="false"
                 value="Throw ViewExpiredException!" />
<p:commandButton actionListener="#{exceptionHandlerView.throwNullPointerException}"
                 ajax="false"
                 value="Throw NullPointerException!" />


<p:ajaxExceptionHandler type="javax.faces.application.ViewExpiredException"
                        update="exceptionDialog"
                        onexception="PF('exceptionDialog').show();" />

<p:ajaxExceptionHandler type="java.lang.NullPointerException"
                        update="exceptionDialog"
                        onexception="PF('exceptionDialog').show();" />

<p:dialog id="exceptionDialog" header="Exception '#{pfExceptionHandler.type}' occured!" widgetVar="exceptionDialog"
          height="500px">
    Message: #{pfExceptionHandler.message} <br/>
    StackTrace: <h:outputText value="#{pfExceptionHandler.formattedStackTrace}" escape="false" /> <br />

    <p:button onclick="document.location.href = document.location.href;"
              value="Reload!"
              rendered="#{pfExceptionHandler.type == 'javax.faces.application.ViewExpiredException'}" …
Run Code Online (Sandbox Code Playgroud)

ajax jsf exception-handling primefaces jsf-2

4
推荐指数
1
解决办法
8243
查看次数

标签 统计

ajax ×1

exception-handling ×1

jsf ×1

jsf-2 ×1

primefaces ×1