You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/01/03 23:21:08 UTC
svn commit: r608659 - in
/myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces:
application/DefaultViewHandlerSupport.java lifecycle/RestoreViewExecutor.java
Author: skitching
Date: Thu Jan 3 14:21:07 2008
New Revision: 608659
URL: http://svn.apache.org/viewvc?rev=608659&view=rev
Log:
More changes for MYFACES-1798 : handle URLs with dots in them correctly.
Modified:
myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/application/DefaultViewHandlerSupport.java
myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java
Modified: myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/application/DefaultViewHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/application/DefaultViewHandlerSupport.java?rev=608659&r1=608658&r2=608659&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/application/DefaultViewHandlerSupport.java (original)
+++ myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/application/DefaultViewHandlerSupport.java Thu Jan 3 14:21:07 2008
@@ -197,10 +197,11 @@
if (!viewId.endsWith(defaultSuffix))
{
StringBuilder builder = new StringBuilder(viewId);
- int index = viewId.lastIndexOf('.');
- if (index != -1)
+ int slashPos = viewId.lastIndexOf('/');
+ int extensionPos = viewId.lastIndexOf('.');
+ if (extensionPos > -1 && extensionPos > slashPos)
{
- builder.replace(index, viewId.length(), defaultSuffix);
+ builder.replace(extensionPos, viewId.length(), defaultSuffix);
}
else
{
Modified: myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java?rev=608659&r1=608658&r2=608659&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java (original)
+++ myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java Thu Jan 3 14:21:07 2008
@@ -143,7 +143,7 @@
String viewId = externalContext.getRequestPathInfo(); // getPathInfo
if (viewId == null)
{
- // No extra path info found, so it is propably extension mapping
+ // No extra path info found, so it is probably extension mapping
viewId = externalContext.getRequestServletPath(); // getServletPath
DebugUtils.assertError(viewId != null, log,
"RequestServletPath is null, cannot determine viewId of current page.");
@@ -152,19 +152,22 @@
// TODO: JSF Spec 2.2.1 - what do they mean by "if the default
// ViewHandler implementation is used..." ?
+ // - probably that this should use DefaultViewHandlerSupport.calculateServletFacesMapping
+ // rather than duplicating the logic here.
String defaultSuffix = externalContext.getInitParameter(ViewHandler.DEFAULT_SUFFIX_PARAM_NAME);
String suffix = defaultSuffix != null ? defaultSuffix : ViewHandler.DEFAULT_SUFFIX;
DebugUtils.assertError(suffix.charAt(0) == '.', log, "Default suffix must start with a dot!");
- int dot = viewId.lastIndexOf('.');
- if (dot == -1)
+ int slashPos = viewId.lastIndexOf('/');
+ int extensionPos = viewId.lastIndexOf('.');
+ if (extensionPos == -1 || extensionPos <= slashPos)
{
log.error("Assumed extension mapping, but there is no extension in " + viewId);
viewId = null;
}
else
{
- viewId = viewId.substring(0, dot) + suffix;
+ viewId = viewId.substring(0, extensionPos) + suffix;
}
}