Author: pete.muir(a)jboss.org
Date: 2008-09-18 07:45:03 -0400 (Thu, 18 Sep 2008)
New Revision: 9017
Modified:
trunk/src/main/org/jboss/seam/mock/MockViewHandler.java
Log:
JBSEA-3426 part 1
Modified: trunk/src/main/org/jboss/seam/mock/MockViewHandler.java
===================================================================
--- trunk/src/main/org/jboss/seam/mock/MockViewHandler.java 2008-09-18 11:41:48 UTC (rev
9016)
+++ trunk/src/main/org/jboss/seam/mock/MockViewHandler.java 2008-09-18 11:45:03 UTC (rev
9017)
@@ -8,6 +8,7 @@
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
+import org.jboss.seam.util.Faces;
import org.jboss.seam.util.Strings;
public class MockViewHandler extends ViewHandler {
@@ -35,25 +36,34 @@
{
String contextPath = ctx.getExternalContext().getRequestContextPath();
String pathInfo = ctx.getExternalContext().getRequestPathInfo();
- String servletPath = ctx.getExternalContext().getRequestServletPath();
-
+ String servletPath = ctx.getExternalContext().getRequestServletPath();
+
if (Strings.isEmpty(pathInfo))
{
- int loc = viewId.lastIndexOf('.');
- if (loc < 0)
- throw new IllegalArgumentException("no file extension in view id: "
+ viewId);
int sploc = servletPath.lastIndexOf('.');
if (sploc < 0)
+ {
throw new IllegalArgumentException("no file extension in servlet path:
" + servletPath);
- return contextPath + viewId.substring(0, loc) + servletPath.substring(sploc);
+ }
+ return contextPath + getViewIdSansSuffix(viewId) +
servletPath.substring(sploc);
}
else
{
- return contextPath + servletPath + viewId;
+ return contextPath + viewId;
}
}
+ private static String getViewIdSansSuffix(String viewId)
+ {
+ int loc = viewId.lastIndexOf('.');
+ if (loc < 0)
+ {
+ throw new IllegalArgumentException("no file extension in view id: " +
viewId);
+ }
+ return viewId.substring(0, loc);
+ }
+
@Override
public String getResourceURL(FacesContext ctx, String url)
{
Show replies by date