You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2011/04/01 02:40:55 UTC
svn commit: r1087527 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/Link.java
main/java/org/apache/tapestry5/internal/services/LinkImpl.java
test/java/org/apache/tapestry5/internal/services/LinkImplTest.java
Author: hlship
Date: Fri Apr 1 00:40:55 2011
New Revision: 1087527
URL: http://svn.apache.org/viewvc?rev=1087527&view=rev
Log:
TAP5-922: Allow a null or blank value to be supplied in Link.addParameter(), and render out the parameter name with the missing value
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Link.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/LinkImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkImplTest.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Link.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Link.java?rev=1087527&r1=1087526&r2=1087527&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Link.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Link.java Fri Apr 1 00:40:55 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2010 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2010, 2011 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ public interface Link
* @param parameterName
* the name of the parameter to store
* @param value
- * the value to store
+ * the value to store, a null or blank value is allowed (as of Tapestry 5.3)
* @throws IllegalArgumentException
* if the link already has a parameter with the given name
*/
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/LinkImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/LinkImpl.java?rev=1087527&r1=1087526&r2=1087527&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/LinkImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/LinkImpl.java Fri Apr 1 00:40:55 2011
@@ -1,4 +1,4 @@
-// Copyright 2009, 2010 The Apache Software Foundation
+// Copyright 2009, 2010, 2011 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -72,11 +72,11 @@ public class LinkImpl implements Link
public void addParameter(String parameterName, String value)
{
assert InternalUtils.isNonBlank(parameterName);
- assert InternalUtils.isNonBlank(value);
+
if (parameters == null)
parameters = CollectionFactory.newMap();
- parameters.put(parameterName, value);
+ parameters.put(parameterName, value == null ? "" : value);
}
public String getBasePath()
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkImplTest.java?rev=1087527&r1=1087526&r2=1087527&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/LinkImplTest.java Fri Apr 1 00:40:55 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2009, 2010 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -258,4 +258,30 @@ public class LinkImplTest extends Intern
assertNull(link.getParameterValue("fred"));
assertListsEquals(link.getParameterNames(), "barney");
}
+
+ /**
+ * TAP5-922
+ *
+ * @since 5.3.0
+ */
+ @Test
+ public void null_parameter_value()
+ {
+ Response response = mockResponse();
+
+ String expectedURI = "/ctx/foo?barney=&fred=flintstone";
+ train_encodeURL(response, expectedURI, expectedURI);
+
+ replay();
+
+ Link link = new LinkImpl("/ctx/foo", false, LinkSecurity.INSECURE, response, null, null);
+
+ link.addParameter("fred", "flintstone");
+ link.addParameter("barney", null);
+
+ assertEquals(link.toURI(), expectedURI);
+
+ verify();
+
+ }
}