jsf - p:commandButton don't redirect when ExternalContext#redirect() is called -


here's example button can throw exception:

<h:commandbutton value="save" update=":formtable:tabledata">     <f:setpropertyactionlistener value="btn_one"         target="#{tamplatetablebean.buttonselected}" /> </h:commandbutton> 

in exceptionhandler have:

facescontext.getcurrentinstance().getexternalcontext().redirect("error.xhtml"); 

when use <h:commandbutton> (as above example) , exception occurs, redirect executed , error page displayed. when use <p:commandbutton>, redirect not happening (even though line redirect("error.xhtml") executed) , stay on same page if nothing happened. exception caught in exceptionhandler, jsf error page not displayed.

how caused , how can solve it?

as describe in link iin balusc comment - omnifaces solve problem. remove excetionhandler implementation , change omnifaces -> in docs, import omnifaces.jar, add faces-config.xml

<factory>   <exception-handler-factory>      org.omnifaces.exceptionhandler.fullajaxexceptionhandlerfactory   </exception-handler-factory> </factory>  

and web.xml

 <error-page>        <error-code>500</error-code>    <location>/faces/restricted/error.xhtml</location>   </error-page>  

now catch exception in ajax request , redirect error page. (tip: error.xhtml facelet file , careful put correct path it)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -