Update of /var/cvs/applications/taglib/src/org/mmbase/bridge/jsp/taglib/pageflow
In directory james.mmbase.org:/tmp/cvs-serv11956
Modified Files:
Url.java UrlTag.java
Log Message:
could not add list-parameters anymore (as it was in 1.8). Bug was shown by
/mmbase/test/test/urls)
See also:
http://cvs.mmbase.org/viewcvs/applications/taglib/src/org/mmbase/bridge/jsp/taglib/pageflow
Index: Url.java
===================================================================
RCS file:
/var/cvs/applications/taglib/src/org/mmbase/bridge/jsp/taglib/pageflow/Url.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- Url.java 22 Feb 2008 14:10:14 -0000 1.39
+++ Url.java 11 Apr 2008 11:42:47 -0000 1.40
@@ -35,7 +35,7 @@
* <p>
* The creation of the URL is delegated to the MMBase framework.
* </p>
- * @version $Id: Url.java,v 1.39 2008/02/22 14:10:14 michiel Exp $;
+ * @version $Id: Url.java,v 1.40 2008/04/11 11:42:47 michiel Exp $;
* @since MMBase-1.9
*/
public class Url implements Comparable, CharSequence, Casting.Unwrappable {
@@ -280,4 +280,31 @@
public int compareTo(Object o) {
return toString().compareTo(Casting.toString(o));
}
+ /**
+ * Add a key/value pair to a map, but does not replace the already
exsiting mapping.
+ * In stead, the already mapped value is converted to a list, contain both
values.
+ */
+ public static Map<String, Object> addParameter(Map<String, Object> map,
String key, Object value) {
+ if (map.containsKey(key)) {
+ log.debug("map already contains mapping for " + key);
+ Object existingValue = map.get(key);
+ if (existingValue instanceof ImplicitList) {
+ log.trace("Adding to existing");
+ ((ImplicitList) existingValue).add(value);
+ } else {
+ List listValue = new ImplicitList();
+ listValue.add(existingValue);
+ listValue.add(value);
+ map.put(key, listValue);
+ }
+ } else {
+ map.put(key, value);
+ }
+ return map;
+ }
+ static class ImplicitList extends ArrayList {
+ ImplicitList() {
+ }
+ }
+
}
Index: UrlTag.java
===================================================================
RCS file:
/var/cvs/applications/taglib/src/org/mmbase/bridge/jsp/taglib/pageflow/UrlTag.java,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -b -r1.114 -r1.115
--- UrlTag.java 17 Mar 2008 16:18:15 -0000 1.114
+++ UrlTag.java 11 Apr 2008 11:42:48 -0000 1.115
@@ -30,7 +30,7 @@
* A Tag to produce an URL with parameters. It can use 'context' parameters
easily.
*
* @author Michiel Meeuwissen
- * @version $Id: UrlTag.java,v 1.114 2008/03/17 16:18:15 michiel Exp $
+ * @version $Id: UrlTag.java,v 1.115 2008/04/11 11:42:48 michiel Exp $
*/
public class UrlTag extends CloudReferrerTag implements ParamHandler,
FrameworkParamHandler {
@@ -98,7 +98,7 @@
public void addParameter(String key, Object value) throws JspTagException {
- extraParameters.put(key, value);
+ Url.addParameter(extraParameters, key, value);
if (url != null) {
url.invalidate();
}
@@ -111,7 +111,7 @@
* @since MMBase-1.9
*/
public void addFrameworkParameter(String key, Object value) throws
JspTagException {
- frameworkParameters.put(key, value);
+ Url.addParameter(frameworkParameters, key, value);
if (url != null) {
url.invalidate();
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs