JARCH SHOWCASE
JARCH SHOWCASE
ExceptionHandler PrimeFaces provides a powerful ExceptionHandler out of the box featuring support for ajax and non-ajax requests, ability to use error-page configuration in web.xml, an EL extension called to provide information about the exception and the p:ajaxExceptionHandler component to handle ajax exceptions at the same page.

AJAX

Non-AJAX

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

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


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

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

    <a: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 />

        <a:button onclick="document.location.href = document.location.href;"
                  value="Reload!"
                  rendered="#{pfExceptionHandler.type == 'javax.faces.application.ViewExpiredException'}" />
    </a:dialog>
</a:form>
                
JARCH, Copyright © 2022 All rights reserved. Running JARCH 24.3.0-SNAPSHOT on PrimeFaces-12.0.0 on Mojarra-2.3.13.