[jboss-cvs] jboss-seam/src/main/org/jboss/seam/servlet ...
Gavin King
gavin.king at jboss.com
Wed Sep 27 19:14:42 EDT 2006
User: gavin
Date: 06/09/27 19:14:42
Modified: src/main/org/jboss/seam/servlet SeamRedirectFilter.java
Log:
propagate page parameters across navigation rule redirects
improvements to framework
Revision Changes Path
1.7 +43 -0 jboss-seam/src/main/org/jboss/seam/servlet/SeamRedirectFilter.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SeamRedirectFilter.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/servlet/SeamRedirectFilter.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- SeamRedirectFilter.java 12 Jul 2006 19:59:57 -0000 1.6
+++ SeamRedirectFilter.java 27 Sep 2006 23:14:42 -0000 1.7
@@ -1,7 +1,10 @@
package org.jboss.seam.servlet;
import java.io.IOException;
+import java.util.Map;
+import javax.faces.application.ViewHandler;
+import javax.faces.context.FacesContext;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -13,6 +16,7 @@
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Manager;
+import org.jboss.seam.core.Pages;
/**
* Propagates the conversation context across a browser redirect
@@ -39,6 +43,12 @@
{
if ( Contexts.isEventContextActive() )
{
+ String viewId = getViewId(url);
+ if (viewId!=null)
+ {
+ Map<String, Object> parameters = Pages.instance().getParameters(viewId);
+ url = Manager.instance().encodeParameters(url, parameters);
+ }
url = Manager.instance().appendConversationIdFromRedirectFilter(url);
}
super.sendRedirect(url);
@@ -48,4 +58,37 @@
public void destroy() {}
+ public static String getViewId(String url)
+ {
+ String servletPath = FacesContext.getCurrentInstance().getExternalContext().getRequestServletPath();
+ String contextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
+ String pathInfo = FacesContext.getCurrentInstance().getExternalContext().getRequestPathInfo();
+ if ( url.startsWith(contextPath) )
+ {
+ String extension = servletPath.substring( servletPath.indexOf('.') );
+ if ( url.endsWith(extension) || url.contains(extension + '?') )
+ {
+ int loc = url.indexOf('?');
+ if (loc<0) loc = url.length();
+ String suffix = getSuffix();
+ return url.substring(contextPath.length(), loc - suffix.length() + 1) + suffix;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public static String getSuffix()
+ {
+ String defaultSuffix = FacesContext.getCurrentInstance().getExternalContext()
+ .getInitParameter(ViewHandler.DEFAULT_SUFFIX_PARAM_NAME);
+ return defaultSuffix == null ? ViewHandler.DEFAULT_SUFFIX : defaultSuffix;
+
+ }
}
More information about the jboss-cvs-commits
mailing list