You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ja...@apache.org on 2010/07/13 16:25:05 UTC
svn commit: r963724 - in /myfaces/core/trunk/impl/src:
main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java
Author: jakobk
Date: Tue Jul 13 14:25:05 2010
New Revision: 963724
URL: http://svn.apache.org/viewvc?rev=963724&view=rev
Log:
MYFACES-2815 includeViewParams=true can also be faces-include-view-params=true (spec rev A) (including test case and minor fix)
The minor fix is changing indexOf() to lastIndexOf() on the file extension identification.
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java?rev=963724&r1=963723&r2=963724&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java Tue Jul 13 14:25:05 2010
@@ -225,9 +225,7 @@ public class NavigationHandlerImpl
String viewIdToTest = outcome;
// If viewIdToTest contains a query string, remove it and set queryString with that value.
-
index = viewIdToTest.indexOf ("?");
-
if (index != -1)
{
queryString = viewIdToTest.substring (index + 1);
@@ -239,24 +237,20 @@ public class NavigationHandlerImpl
isRedirect = true;
}
- // If queryString contains "includeViewParams=true", set includeViewParams to true.
- if (queryString.indexOf ("includeViewParams=true") != -1)
+ // If queryString contains "includeViewParams=true" or
+ // "faces-include-view-params=true", set includeViewParams to true.
+ if (queryString.indexOf("includeViewParams=true") != -1
+ || queryString.indexOf("faces-include-view-params=true") != -1)
{
includeViewParams = true;
}
}
- // FIXME: the spec states that redirection (i.e., isRedirect=true) is implied when preemptive navigation is performed,
- // though I'm not sure how we're supposed to determine that.
-
// If viewIdToTest does not have a "file extension", use the one from the current viewId.
- // TODO: I don't know exactly what the spec means by "file extension". I'm assuming everything after "."
-
index = viewIdToTest.indexOf (".");
-
if (index == -1)
{
- index = viewId.indexOf (".");
+ index = viewId.lastIndexOf(".");
if (index != -1)
{
@@ -299,7 +293,7 @@ public class NavigationHandlerImpl
if (implicitViewId != null)
{
// Append all params from the queryString
- // (excluding faces-redirect and includeViewParams)
+ // (excluding faces-redirect, includeViewParams and faces-include-view-params)
Map<String, List<String>> params = null;
if (queryString != null && !"".equals(queryString))
{
@@ -312,9 +306,10 @@ public class NavigationHandlerImpl
{
// valid parameter - add it to params
if ("includeViewParams".equals(splitParam[0])
+ || "faces-include-view-params".equals(splitParam[0])
|| "faces-redirect".equals(splitParam[0]))
{
- // ignore includeViewParams and faces-redirect
+ // ignore includeViewParams, faces-include-view-params and faces-redirect
continue;
}
List<String> paramValues = params.get(splitParam[0]);
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java?rev=963724&r1=963723&r2=963724&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/NavigationHandlerImplTest.java Tue Jul 13 14:25:05 2010
@@ -529,5 +529,40 @@ public class NavigationHandlerImplTest e
// should not be added as a parameter
Assert.assertEquals(expected, navigationCase.getParameters());
+ Assert.assertTrue("includeViewParams=true in the query String must "
+ + "set includeViewParams to true.", navigationCase.isIncludeViewParams());
+ Assert.assertTrue("redirect=true in the query String must "
+ + "set redirect to true.", navigationCase.isRedirect());
+ }
+
+ /**
+ * Tests if the URL parameters of an outcome are correctly
+ * added to the NavigationCase.
+ * Identically to testFacesRedirectAddsUrlParameters(), except that
+ * it uses faces-include-view-params=true instead of includeViewParams=true.
+ */
+ @Test
+ public void testFacesRedirectAddsUrlParametersFacesIncludeViewParams()
+ {
+ NavigationHandlerImpl nh = new NavigationHandlerImpl();
+
+ // get the NavigationCase
+ // note that the URL parameters can be separated via & or &
+ NavigationCase navigationCase = nh.getNavigationCase(facesContext, null,
+ "test.xhtml?faces-redirect=true&a=b&faces-include-view-params=true&c=d&e=f");
+
+ // created the expected parameter map
+ Map<String, List<String>> expected = new HashMap<String, List<String>>();
+ expected.put("a", Arrays.asList("b"));
+ expected.put("c", Arrays.asList("d"));
+ expected.put("e", Arrays.asList("f"));
+ // note that faces-redirect and faces-include-view-params
+ // should not be added as a parameter
+
+ Assert.assertEquals(expected, navigationCase.getParameters());
+ Assert.assertTrue("faces-include-view-params=true in the query String must "
+ + "set includeViewParams to true.", navigationCase.isIncludeViewParams());
+ Assert.assertTrue("redirect=true in the query String must "
+ + "set redirect to true.", navigationCase.isRedirect());
}
}