Changed visibility of BaseTemplateModel.servletContext

This commit is contained in:
rjy7 2010-06-25 14:14:46 +00:00
parent fb0377134b
commit 22eb6677f5
3 changed files with 11 additions and 3 deletions

View file

@ -22,7 +22,7 @@ public class FreeMarkerSetup implements ServletContextListener {
ServletContext sc = event.getServletContext(); ServletContext sc = event.getServletContext();
sc.setAttribute("themeToConfigMap", new HashMap<String, Configuration>()); sc.setAttribute("themeToConfigMap", new HashMap<String, Configuration>());
BaseTemplateModel.context = sc; BaseTemplateModel.setServletContext(sc);
FreeMarkerComponentGenerator.setServletContext(sc); FreeMarkerComponentGenerator.setServletContext(sc);
UrlBuilder.contextPath = sc.getContextPath(); UrlBuilder.contextPath = sc.getContextPath();
} }

View file

@ -14,7 +14,7 @@ public abstract class BaseTemplateModel {
private static final Log log = LogFactory.getLog(BaseTemplateModel.class.getName()); private static final Log log = LogFactory.getLog(BaseTemplateModel.class.getName());
public static ServletContext context = null; protected static ServletContext servletContext = null;
// Wrap UrlBuilder method so templates can call ${item.url} // Wrap UrlBuilder method so templates can call ${item.url}
public String getUrl(String path) { public String getUrl(String path) {
@ -26,6 +26,14 @@ public abstract class BaseTemplateModel {
return UrlBuilder.getUrl(path, params); return UrlBuilder.getUrl(path, params);
} }
public static ServletContext getServletContext() {
return servletContext;
}
public static void setServletContext(ServletContext context) {
BaseTemplateModel.servletContext = context;
}
/* /*
* public static List<?> wrapList(List<?> list, Class cl) * public static List<?> wrapList(List<?> list, Class cl)
* throw error if cl not a child of ViewObject * throw error if cl not a child of ViewObject

View file

@ -56,7 +56,7 @@ public class IndividualTemplateModel extends BaseTemplateModel {
private String getView(ClassView view) { private String getView(ClassView view) {
ViewFinder vf = new ViewFinder(view); ViewFinder vf = new ViewFinder(view);
return vf.findClassView(individual, context); return vf.findClassView(individual, servletContext);
} }
public Link getPrimaryLink() { public Link getPrimaryLink() {