1

I am facing an issue with p:ajaxExceptionHandler. The p:ajaxExceptionHandler code does not seem to get invoked at all.. I have the configuration in web.xml as per primefaces documentation. Basically When an exception occurs, I want to show a pop up on the same page that is not happening

In the console I see the error,

<Jul 27, 2015 2:33:22 PM EDT> <Error> <javax.faces.event> <BEA-000000> <Received
 'java.lang.NullPointerException' when invoking action listener '#{BeanName.methodName()}' for component 'delete'>
<Jul 27, 2015 2:33:22 PM EDT> <Error> <javax.faces.event> <BEA-000000> <java.lan
g.NullPointerException: Exception

I dont want to be redirected to a different page, but just tried adding an entry in web.xml to check if that works but still I get the same error.

My requirement is to show a pop dialog conditionally. In the backing bean I have a checkPopup method which will throw an exception if some condition is not met which is when I want to show the pop up. Please help me if I am missing something. Thanks!

MyCode

<p:commandButton id="delete" value="Save and Proceed" styleClass="deleteBtn" type="submit"  icon="ui-icon-disk" actionListener="#{BeanName.checkPopUp()}"
                            update=":cbForm:topPanel check" ajax="true" >
            </p:commandButton>
            <p:ajaxExceptionHandler type="java.lang.NullPointerException" update="check" onexception="PF('confirmDlg').show()" /> 
                    <p:confirmDialog rendered="#{BeanName.methodName()}" id="check" header="confirmation" widgetVar="confirmDlg" global="true"  severity="info" closable="false">
                        <f:facet name="message">
                        <h:outputText value="#BeanName.BeanName.dialogMsg}"/>
                        </f:facet>
                        <p:commandButton value="#{resbndl.btnOK}" type="submit" process="@this" action="#{BeanName.methodName()}" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" onstart="PF('confirmDlg').hide()" update=":cForm:tView:check"/>
                        <p:commandButton value="#{resbndl.btnCancel}" type="submit" process="@this" action="#{BeanName.methodName()}" update=":cForm:tView:fieldName"  styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
                    </p:confirmDialog>  

checkPopUp code

public String checkPopUp (){
        if (value == null)
            throw new java.lang.NullPointerException("Exception");
        return validate(2);
    }
  • 1
    why not just display the message from the method and not throw the exception in the first place? – dramzy Jul 27 '15 at 19:14
  • If you're confident you've done all the proper server-side config, check your javascript console for more clues – kolossus Jul 28 '15 at 03:48
  • Thanks for the comments, from my reading of RequestContext I assumed that there is more configuration to do. But after reading the comment, I tried with showing the dialog from the backing bean and it works fine for my requirement. RequestContext context = RequestContext.getCurrentInstance(); context.execute("PF('confirmDlg').show()"); – user5161658 Jul 28 '15 at 13:25

0 Answers0