From 3b1af34482189b495533ea47e9c18e385a4224e9 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 14 Mar 2012 12:27:04 -0400 Subject: [PATCH] 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. --- build-spring-webflow/resources/changelog.txt | 9 +++++++-- .../faces/webflow/JsfAjaxHandler.java | 12 +++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/build-spring-webflow/resources/changelog.txt b/build-spring-webflow/resources/changelog.txt index 5e41e688..144e4d9f 100644 --- a/build-spring-webflow/resources/changelog.txt +++ b/build-spring-webflow/resources/changelog.txt @@ -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) ----------------------------------------------- diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfAjaxHandler.java b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfAjaxHandler.java index b9934c07..1678b0d3 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfAjaxHandler.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfAjaxHandler.java @@ -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,