A simple StringWrapper object that can be used to get around the general HTML auto-encoding now done in FTL rendered through the Screen Widget; just call the static method to wrap it and it will insert fine and the encoder will leave it alone

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@742412 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David E. Jones
2009-02-09 11:55:07 +00:00
parent 1859744a3f
commit 5d8d243a26
2 changed files with 38 additions and 2 deletions
@@ -18,19 +18,19 @@
*******************************************************************************/
package org.ofbiz.base.util;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;
import java.io.Serializable;
/**
* Contains extra information about Messages
*
*/
@SuppressWarnings("serial")
public class MessageString implements Serializable {
public static final String module = MessageString.class.getName();
@@ -626,5 +626,41 @@ public class StringUtil {
return sb.toString();
}
public static StringWrapper makeStringWrapper(String theString) {
if (theString == null) return null;
if (theString.length() == 0) return StringWrapper.EMPTY_STRING_WRAPPER;
return new StringWrapper(theString);
}
/**
* A super-lightweight object to wrap a String object. Mainly used with FTL templates
* to avoid the general HTML auto-encoding that is now done through the Screen Widget.
*/
public static class StringWrapper {
public static final StringWrapper EMPTY_STRING_WRAPPER = new StringWrapper("");
protected String theString;
protected StringWrapper() { }
public StringWrapper(String theString) {
this.theString = theString;
}
/**
* Fairly simple method used for the plus (+) base concatenation in Groovy.
*
* @param value
* @return
*/
public String plus(Object value) {
return this.theString + value;
}
/**
* @return The String this object wraps.
*/
public String toString() {
return this.theString;
}
}
}