Here's an example button which can throw an exception:
<h:commandButton value="save" update=":formTable:tableData">
<f:setPropertyActionListener value="BTN_ONE"
target="#{tamplateTableBean.buttonSelected}" />
</h:commandButton>
In my ExceptionHandler
I have:
FacesContext.getCurrentInstance().getExternalContext().redirect("error.xhtml");
When I use <h:commandButton>
(as above example) and an exception occurs, then redirect is executed and error page is displayed.
When I use <p:commandButton>
, then redirect is not happening (even though line redirect("error.xhtml")
is executed) and it will stay on the same page as if nothing happened. The exception is caught in my ExceptionHandler
, but JSF error page is not displayed.
How is this caused and how can I solve it?