[Actionframework-users] bug fix in org/actionframework/engines/velocity/VelocityServlet.java
Status: Inactive
Brought to you by:
ptoman
|
From: Mark D. A. <md...@di...> - 2002-09-24 07:19:41
|
The logic in org/actionframework/engines/velocity/VelocityServlet.java
to relativize the value of FILE_RESOURCE_LOADER_PATH is incorrect
if there is a comma-separated value, which is supported by velocity.
Velocity does this by using org.apache.commons.collections.ExtendedProperties
AS could do that too, but i didn't want to make a deep change.
Rather, i just added this function.
-mda
------------------------------------
// deal with the fact that this might comma separated, not just a single token
protected String relativize_loader_path(Properties p, String v) {
StringBuffer sb = new StringBuffer("");
java.util.StringTokenizer st = new java.util.StringTokenizer(v, ", ");
while (st.hasMoreTokens()) {
String f = st.nextToken();
String real_path = getServletContext().getRealPath(f);
if (real_path == null) {
_getLog("Velocity").error("[init] " + "Cannot get real path of template path '" + f + "'");
} else {
_getLog("Velocity").info("Template path = '" + real_path + "'");
f = real_path;
}
if (sb.length() > 0) sb.append(",");
sb.append(f);
}
String new_val = sb.toString();
p.put(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, new_val);
_getLog("Velocity").info("new value of " + RuntimeConstants.FILE_RESOURCE_LOADER_PATH + " = '" + new_val + "'");
return new_val;
}
....
// "file.resource.loader.path" property
String templatePath = p.getProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH);
if (templatePath != null) {
relativize_loader_path(p, templatePath);
} else _getLog("Velocity").warning("Template path '"+ RuntimeConstants.FILE_RESOURCE_LOADER_PATH +"' not specified");
...
|