This commit is contained in:
Keith Donald
2008-04-29 03:38:21 +00:00
parent ac04db9067
commit a9638eb643
4 changed files with 39 additions and 29 deletions

View File

@@ -19,12 +19,12 @@
<classpathentry kind="var" path="IVY_CACHE/org.jboss.el/com.springsource.org.jboss.el/2.0.0.GA/com.springsource.org.jboss.el-2.0.0.GA.jar" sourcepath="IVY_CACHE/org.jboss.seam/jboss-el/jboss-el-sources-2.0.0.GA.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.junit/3.8.2/com.springsource.junit-3.8.2.jar" sourcepath="/IVY_CACHE/org.junit/junit/junit-sources-3.8.2.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.richfaces/com.springsource.org.richfaces/3.1.4.GA/com.springsource.org.richfaces-3.1.4.GA.jar" sourcepath="IVY_CACHE/org.richfaces.framework/richfaces-api/richfaces-api-sources-3.1.4.GA.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.beans/2.5.3.A/org.springframework.beans-2.5.3.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-beans/spring-beans-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.context/2.5.3.A/org.springframework.context-2.5.3.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-context/spring-context-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.core/2.5.3.A/org.springframework.core-2.5.3.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-core/spring-core-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.test/2.5.3.A/org.springframework.test-2.5.3.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-test/spring-test-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.web/2.5.3.A/org.springframework.web-2.5.3.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-web/spring-web-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.web.servlet/2.5.3.A/org.springframework.web.servlet-2.5.3.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-webmvc/spring-webmvc-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.beans/2.5.4.A/org.springframework.beans-2.5.4.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-beans/spring-beans-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.context/2.5.4.A/org.springframework.context-2.5.4.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-context/spring-context-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.core/2.5.4.A/org.springframework.core-2.5.4.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-core/spring-core-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.test/2.5.4.A/org.springframework.test-2.5.4.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-test/spring-test-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.web/2.5.4.A/org.springframework.web-2.5.4.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-web/spring-web-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.web.servlet/2.5.4.A/org.springframework.web.servlet-2.5.4.A.jar" sourcepath="IVY_CACHE/org.springframework/spring-webmvc/spring-webmvc-sources-2.5.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/javax.faces/com.springsource.javax.faces/1.2.0.08/com.springsource.javax.faces-1.2.0.08.jar"/>
<classpathentry kind="var" path="IVY_CACHE/com.sun.faces/com.springsource.com.sun.faces/1.2.0.08/com.springsource.com.sun.faces-1.2.0.08.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/spring-js"/>

View File

@@ -36,8 +36,8 @@
<dependency org="javax.faces" name="com.springsource.javax.faces" rev="1.2.0.08" conf="provided, jsf12->compile" />
<dependency org="com.sun.faces" name="com.springsource.com.sun.faces" rev="1.2.0.08" conf="provided, jsf12->compile" />
<!-- JSF 1.1 dependencies -->
<dependency org="org.apache.myfaces" name="com.springsource.org.apache.myfaces.javax.faces" rev="1.1.5" conf="jsf11->compile" />
<!-- JSF 1.1 dependencies -->
<dependency org="org.apache.myfaces" name="com.springsource.org.apache.myfaces.javax.faces" rev="1.1.5" conf="jsf11->compile" />
<dependency org="org.apache.myfaces" name="com.springsource.org.apache.myfaces" rev="1.1.5" conf="jsf11->compile" />
<!-- test time only dependencies -->

View File

@@ -26,37 +26,47 @@ import javax.servlet.http.HttpServletResponse;
import org.ajax4jsf.context.AjaxContext;
import org.springframework.faces.webflow.FlowLifecycle;
import org.springframework.js.ajax.AjaxHandler;
import org.springframework.js.ajax.SpringJavascriptAjaxHandler;
import org.springframework.web.context.support.WebApplicationObjectSupport;
/**
* Ajax handler that works with Rich Faces, allowing support for Web Flow ajax features with the Rich Faces toolkit.
*
* @author Jeremy Grelle
*/
public class RichFacesAjaxHandler extends SpringJavascriptAjaxHandler {
public class RichFacesAjaxHandler extends WebApplicationObjectSupport {
public boolean isAjaxRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response) {
private AjaxHandler delegate = new SpringJavascriptAjaxHandler();
public boolean isAjaxRequest(HttpServletRequest request, HttpServletResponse response) {
FacesContextHelper helper = new FacesContextHelper();
if (AjaxContext.getCurrentInstance(helper.getFacesContext(context, request, response)).isAjaxRequest(
helper.getFacesContext(context, request, response))) {
try {
if (AjaxContext.getCurrentInstance(helper.getFacesContext(getServletContext(), request, response))
.isAjaxRequest(helper.getFacesContext(getServletContext(), request, response))) {
return true;
} else {
return delegate.isAjaxRequest(request, response);
}
} finally {
helper.cleanup();
return true;
} else {
helper.cleanup();
return super.isAjaxRequest(context, request, response);
}
}
public void sendAjaxRedirect(ServletContext context, HttpServletRequest request, HttpServletResponse response,
String targetUrl, boolean popup) throws IOException {
public void sendAjaxRedirect(String targetUrl, HttpServletRequest request, HttpServletResponse response,
boolean popup) throws IOException {
FacesContextHelper helper = new FacesContextHelper();
if (AjaxContext.getCurrentInstance(helper.getFacesContext(context, request, response)).isAjaxRequest(
helper.getFacesContext(context, request, response))) {
try {
if (AjaxContext.getCurrentInstance(helper.getFacesContext(getServletContext(), request, response))
.isAjaxRequest(helper.getFacesContext(getServletContext(), request, response))) {
helper.cleanup();
response.sendRedirect(response.encodeRedirectURL(targetUrl));
} else {
helper.cleanup();
delegate.sendAjaxRedirect(targetUrl, request, response, popup);
}
} finally {
helper.cleanup();
response.sendRedirect(response.encodeRedirectURL(targetUrl));
} else {
helper.cleanup();
super.sendAjaxRedirect(context, request, response, targetUrl, popup);
}
}

View File

@@ -35,7 +35,6 @@ import org.springframework.context.ApplicationContext;
import org.springframework.core.io.ContextResource;
import org.springframework.core.io.Resource;
import org.springframework.faces.ui.AjaxViewRoot;
import org.springframework.js.ajax.AjaxHandler;
import org.springframework.js.ajax.SpringJavascriptAjaxHandler;
import org.springframework.webflow.context.ExternalContext;
import org.springframework.webflow.execution.RequestContext;
@@ -54,6 +53,8 @@ public class JsfViewFactory implements ViewFactory {
private static final Log logger = LogFactory.getLog(JsfViewFactory.class);
private static SpringJavascriptAjaxHandler springJsAjaxHandler = new SpringJavascriptAjaxHandler();
private final Expression viewIdExpression;
private final Lifecycle lifecycle;
@@ -136,11 +137,10 @@ public class JsfViewFactory implements ViewFactory {
}
private boolean isSpringJavascriptAjaxRequest(ExternalContext context) {
// this is not very clean
// consider factoring out into external context
if (context.getNativeContext() instanceof ServletContext) {
AjaxHandler handler = new SpringJavascriptAjaxHandler();
return handler.isAjaxRequest((ServletContext) context.getNativeContext(), (HttpServletRequest) context
.getNativeRequest(), (HttpServletResponse) context.getNativeResponse());
return springJsAjaxHandler.isAjaxRequest((HttpServletRequest) context.getNativeRequest(),
(HttpServletResponse) context.getNativeResponse());
} else {
return false;
}