Check request param to recognize JSF 2 Ajax requests

Previously we checked the "Faces-Request" header only.
Now we try to delegate the call to
PartialViewContext.isAjaxRequest() first. If a FacesContext
is unavailble for some reason we also check the
"javax.faces.partial.ajax" request parameter.
This commit is contained in:
Rossen Stoyanchev
2012-03-14 12:27:04 -04:00
parent da15ce8138
commit 3b1af34482
2 changed files with 16 additions and 5 deletions

View File

@@ -7,9 +7,14 @@ Changes in version 2.3.1.RELEASE
Upgrade JSF Mojarra version to 2.1.7
Modify Jsf2FlowFacesContext.isValidationFailed() to check Web Flow's MessageContext for errors
Recognize class-level bean validation messages in BindingResult.getGlobalErrors()
Fix "embedded" mode to be flow session local, i.e. specific to a specific flow or subflow.
Ensure "embedded" mode is flow session local, i.e. specific to a specific flow or subflow
Allow JSF view root to survive redirect in same state (following fix in JSF Mojarra 2.1)
Ensure PostRestoreStateEvent is delivered to registered listeners.
Ensure PostRestoreStateEvent is delivered to registered listeners
Upgrade booking-faces sample to use PrimeFaces 3.1.1
Fix NullPointerException in FlowViewStateManager when not in a flow request
Move source code to http://github.com/SpringSource/spring-webflow
Modify FlowPartialViewContext to return a modifiable List to comply with its contract
Check request parameter in addition to request header to recognize JSF 2 Ajax requests.
Changes in version 2.3.0.RELEASE (Feb 28, 2011)
-----------------------------------------------

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2010 the original author or authors.
* Copyright 2004-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,8 +50,14 @@ public class JsfAjaxHandler extends AbstractAjaxHandler {
}
protected boolean isAjaxRequestInternal(HttpServletRequest request, HttpServletResponse response) {
String facesRequestHeader = request.getHeader("Faces-Request");
return ("partial/ajax".equals(facesRequestHeader)) ? true : false;
FacesContext facesContext = FlowFacesContext.getCurrentInstance();
if (facesContext != null) {
return facesContext.getPartialViewContext().isAjaxRequest();
} else {
String header = request.getHeader("Faces-Request");
String param = request.getParameter("javax.faces.partial.ajax");
return ("partial/ajax".equals(header) || "true".equals(param)) ? true : false;
}
}
protected void sendAjaxRedirectInternal(final String targetUrl, final HttpServletRequest request,