Update of /var/cvs/applications/taglib/src/org/mmbase/bridge/jsp/taglib/pageflow
In directory james.mmbase.org:/tmp/cvs-serv24255
Modified Files:
Url.java
Log Message:
for backwards compatibilityh with 1.8, support 'appendMoreParameters again.
Renamed 'writemp' parameters to more correct 'escapeamp'
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.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- Url.java 6 Nov 2008 12:24:57 -0000 1.49
+++ Url.java 22 Dec 2008 14:51:49 -0000 1.50
@@ -35,7 +35,7 @@
* <p>
* The creation of the URL is delegated to the MMBase framework.
* </p>
- * @version $Id: Url.java,v 1.49 2008/11/06 12:24:57 michiel Exp $;
+ * @version $Id: Url.java,v 1.50 2008/12/22 14:51:49 michiel Exp $;
* @since MMBase-1.9
*/
public class Url implements Comparable, CharSequence, Casting.Unwrappable {
@@ -51,8 +51,8 @@
private final boolean encodeUrl;
private final boolean escapeAmps;
- private String cacheAmp = null;
- private String cacheNoAmp = null;
+ private String cacheEscapeAmp = null;
+ private String cacheNoEscapeAmp = null;
private String string = null;
private final boolean internal;
private boolean process = false;
@@ -89,6 +89,7 @@
internal = intern;
}
+
public Url(ContextReferrerTag t, String p, String a) throws
JspTagException {
tag = t;
abs = a;
@@ -100,6 +101,17 @@
internal = false;
}
+ Url(Url u, boolean encode) {
+ this.tag = u.tag;
+ this.abs = u.abs;
+ this.encodeUrl = encode;
+ this.escapeAmps = u.escapeAmps;
+ this.page = u.page;
+ this.params = u.params;
+ this.frameworkParams = u.params;
+ this.internal = u.internal;
+ }
+
public static Component getComponent(ContextReferrerTag tag) {
HttpServletRequest req = (HttpServletRequest)
tag.getPageContext().getRequest();
@@ -119,7 +131,7 @@
this.legacy = true;
}
- public String getLegacy(boolean writeamp) throws JspTagException {
+ public String getLegacy(boolean escapeamp) throws JspTagException {
Map<String, Object> m = new HashMap<String, Object>();
if (params != null) {
m.putAll(params);
@@ -127,7 +139,7 @@
if (log.isDebugEnabled()) {
log.debug("legacy url " + page + m);
}
- String res = BasicUrlConverter.getUrl(page, m,
(HttpServletRequest)tag.getPageContext().getRequest(), writeamp).toString();
+ String res = BasicUrlConverter.getUrl(page, m,
(HttpServletRequest)tag.getPageContext().getRequest(), escapeamp).toString();
pageLog.service("getting legacy: " + page + " -> " + res);
return res;
}
@@ -137,12 +149,12 @@
* Returns the URL as a String, always without the application context.
Never <code>null</code>
*/
- public String get(boolean writeamp) throws JspTagException,
FrameworkException {
+ public String get(boolean escapeamp) throws JspTagException,
FrameworkException {
if (legacy) {
- return getLegacy(writeamp);
+ return getLegacy(escapeamp);
}
- String result = writeamp ? cacheAmp : cacheNoAmp;
+ String result = escapeamp ? cacheEscapeAmp : cacheNoEscapeAmp;
if (result != null) {
log.debug("found cached " + result);
return result;
@@ -176,19 +188,26 @@
}
} else {
if (process) {
- result = framework.getProcessUrl(page, params,
frameworkParameters, writeamp);
+ result = framework.getProcessUrl(page, params,
frameworkParameters, escapeamp);
} else {
- result = framework.getUrl(page, params, frameworkParameters,
writeamp);
+ result = framework.getUrl(page, params, frameworkParameters,
escapeamp);
}
if (log.isDebugEnabled()) {
log.debug("Created normal url link to page: " + page + " " +
params + " fw: " + frameworkParameters + " -> " + result + " fw");
}
}
+ {
+ String amp = escapeamp ? "&" : "&";
+ String connector = result.indexOf("?") > 0 ? amp : "?";
+ StringBuffer a = new StringBuffer(result);
+ tag.appendMoreParameters(connector , amp, a);
+ result = a.toString();
+ }
- if (writeamp) {
- cacheAmp = result;
+ if (escapeamp) {
+ cacheEscapeAmp = result;
} else {
- cacheNoAmp = result;
+ cacheNoEscapeAmp = result;
}
return result;
@@ -287,12 +306,16 @@
return string;
}
+ public boolean encodeUrl() {
+ return encodeUrl;
+ }
+
protected void invalidate() {
log.debug("invalidating");
if (params instanceof UrlParameters) {
((UrlParameters) params).invalidate();
}
- string = cacheAmp = cacheNoAmp = null;
+ string = cacheEscapeAmp = cacheNoEscapeAmp = null;
}
public char charAt(int index) {
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs