Hi!
We are working on a web project using Spring Webflow 2.3.1, Mojarra 2.1.10 and PrimeFaces 3.3.1. We want to configure an ExceptionResolver that shows a generic error page for every uncaught exception thrown from our service or dialog layer.
So we added the following lines to our webflow-config.xml
When we throw an exception in one of our service or dialog controller methods that is triggered by a button e.g.Code:<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="defaultErrorView" value="error" /> </bean>
The ExceptionResolver is called and we can see the error in the application log, but we do not see our error page. After some research we finally figured out, that the error page is only shown if we add an update=”@all” to the button in the Facelet page e.g.:Code:<p:commandButton value="Search" action="search" />
So we took a look at the requests that were send to the server in both scenarios. The first button (no update=all) sends a request / got a response like:Code:<p:commandButton value="Search" action="search" update=”@all” />
As you see the response in empty! The second button sends a request / got a response like:Code:POST http://localhost:8090/swf-booking-faces/spring/auftragsuche?execution=e4s1 HTTP/1.1 Host: localhost:8090 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:13.0) Gecko/20100101 Firefox/13.0.1 Accept: application/xml, text/xml, */*; q=0.01 Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Connection: keep-alive Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Faces-Request: partial/ajax X-Requested-With: XMLHttpRequest Referer: http://localhost:8090/swf-booking-faces/spring/auftragsuche?execution=e4s1 Content-Length: 200 Cookie: JSESSIONID=0B4A40285E65A3D02FE8428E1B7769B1 Pragma: no-cache Cache-Control: no-cache javax.faces.partial.ajax=true&javax.faces.source=j_idt17%3Asearch&javax.faces.partial.execute=%40all&j_idt17%3Asearch=j_idt17%3Asearch&j_idt17=j_idt17&j_idt17%3AorderNumber=&javax.faces.ViewState=e4s1 HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Pragma: no-cache Expires: Thu, 01 Jan 1970 00:00:00 GMT Cache-Control: no-cache Cache-Control: no-store X-Powered-By: JSF/2.0 X-Powered-By: JSF/2.0 Cache-Control: no-cache Content-Type: text/xml;charset=UTF-8 Content-Language: de-DE Content-Length: 76 Date: Thu, 22 Nov 2012 19:10:25 GMT <?xml version='1.0' encoding='UTF-8'?> <partial-response></partial-response>
As you can see, the response contains the error page. Both requests are Ajax requests and are absolutely identical except one little detail: the working request got a javax.faces.partial.render=%40all as additional parameter.Code:POST http://localhost:8090/swf-booking-faces/spring/auftragsuche?execution=e3s1 HTTP/1.1 Host: localhost:8090 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:13.0) Gecko/20100101 Firefox/13.0.1 Accept: application/xml, text/xml, */*; q=0.01 Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Connection: keep-alive Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Faces-Request: partial/ajax X-Requested-With: XMLHttpRequest Referer: http://localhost:8090/swf-booking-faces/spring/auftragsuche?execution=e3s1 Content-Length: 234 Cookie: JSESSIONID=0B4A40285E65A3D02FE8428E1B7769B1 Pragma: no-cache Cache-Control: no-cache javax.faces.partial.ajax=true&javax.faces.source=j_idt17%3Asearch&javax.faces.partial.execute=%40all&javax.faces.partial.render=%40all&j_idt17%3Asearch=j_idt17%3Asearch&j_idt17=j_idt17&j_idt17%3AorderNumber=&javax.faces.ViewState=e3s1 HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Pragma: no-cache Expires: Thu, 01 Jan 1970 00:00:00 GMT Cache-Control: no-cache Cache-Control: no-store X-Powered-By: JSF/2.0 X-Powered-By: JSF/2.0 Cache-Control: no-cache Content-Type: text/xml;charset=UTF-8 Content-Language: de-DE Content-Length: 964 Date: Thu, 22 Nov 2012 19:08:25 GMT <?xml version='1.0' encoding='UTF-8'?> <partial-response><changes><update id="javax.faces.ViewRoot"><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><link type="text/css" rel="stylesheet" href="/swf-booking-faces/spring/javax.faces.resource/theme.css?ln=primefaces-aristo" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Fehler</title></head><body>Error!<br /></body> </html>]]></update></changes></partial-response>
Update=@all causes JSF to update the complete form after an ajax request. That is usually not! what we want. In most scenarios Ajax request shall update only a part particular part of the page. Otherwise it makes no sense to use Ajax at all. As consequence the ExceptionResolver do not work in most of our scenarios.
Questions:
1) Is this a Problem of Spring WebFlow or a problem Mojarra or PrimeFaces?
2) Assuming that the problem is caused by Spring Webflow, why does Spring WebFlow shows the described behavior?
3) Is this a bug or a feature?
4) If not a bug what can we do to make the ExceptionResolver working for Ajax request without update=@all?
Any help is highly appreciated!
Regards
Jar-Runner


Reply With Quote