Changed visibility of FreeMarkerHttpServlet root hashmap to private, so other controllers can't add to it.
This commit is contained in:
parent
bbc5765663
commit
6bfab4e431
2 changed files with 13 additions and 45 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@ -42,7 +45,7 @@ public class FreeMarkerComponentGenerator extends FreeMarkerHttpServlet {
|
||||||
|
|
||||||
private String get(String templateName) {
|
private String get(String templateName) {
|
||||||
String template = "page/partials/" + templateName + ".ftl";
|
String template = "page/partials/" + templateName + ".ftl";
|
||||||
return mergeToTemplate(template, root).toString();
|
return mergeTemplateToRoot(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,7 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
||||||
protected String appName;
|
protected String appName;
|
||||||
protected UrlBuilder urlBuilder;
|
protected UrlBuilder urlBuilder;
|
||||||
|
|
||||||
// RY Change to private. Only used now by FreeMarkerComponentGenerator, which
|
private Map<String, Object> root = new HashMap<String, Object>();
|
||||||
// can be moved here as a nested class. Subclasses should not use root.
|
|
||||||
protected Map<String, Object> root = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
public void doGet( HttpServletRequest request, HttpServletResponse response )
|
public void doGet( HttpServletRequest request, HttpServletResponse response )
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
|
@ -344,7 +342,7 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
||||||
return config != null;
|
return config != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TEMPORARY for transition from JSP to FreeMarker. Once transition
|
// TEMPORARY methods for transition from JSP to FreeMarker. Once transition
|
||||||
// is complete and no more pages are generated in JSP, this can be removed.
|
// is complete and no more pages are generated in JSP, this can be removed.
|
||||||
// Do this if FreeMarker is configured (i.e., not Datastar) and if we are not in
|
// Do this if FreeMarker is configured (i.e., not Datastar) and if we are not in
|
||||||
// a FreeMarkerHttpServlet, which will generate identity, menu, and footer from the page template.
|
// a FreeMarkerHttpServlet, which will generate identity, menu, and footer from the page template.
|
||||||
|
@ -356,43 +354,10 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
||||||
request.setAttribute("ftl_search", fcg.getSearch());
|
request.setAttribute("ftl_search", fcg.getSearch());
|
||||||
request.setAttribute("ftl_footer", fcg.getFooter());
|
request.setAttribute("ftl_footer", fcg.getFooter());
|
||||||
}
|
}
|
||||||
|
// This method is called by FreeMarkerComponentGenerator, since root is private.
|
||||||
/**
|
// Don't want to make root protected because other controllers shouldn't add to it.
|
||||||
* TEMPORARY for transition from JSP to FreeMarker. Once transition
|
protected String mergeTemplateToRoot(String template) {
|
||||||
* is complete and no more pages are generated in JSP, this can be removed.
|
return mergeToTemplate(template, root).toString();
|
||||||
*
|
}
|
||||||
* @author rjy7
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// public class FreeMarkerComponentGenerator extends FreeMarkerHttpServlet {
|
|
||||||
//
|
|
||||||
// private static final long serialVersionUID = 1L;
|
|
||||||
//
|
|
||||||
// FreeMarkerComponentGenerator(HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
// doSetup(request, response);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getIdentity() {
|
|
||||||
// return get("identity");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getMenu() {
|
|
||||||
// return get("menu");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getSearch() {
|
|
||||||
// return get("search");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getFooter() {
|
|
||||||
// return get("footer");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private String get(String templateName) {
|
|
||||||
// String template = "partials/" + templateName + ".ftl";
|
|
||||||
// return mergeToTemplate(template, root).toString();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue