* @see freemarker.ext.servlet.FreemarkerServlet#preTemplateProcess(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, freemarker.template.Template, freemarker.template.TemplateModel)
*/
protected boolean preTemplateProcess(HttpServletRequest request, HttpServletResponse response, Template template, TemplateModel templateModel) throws ServletException, IOException {
boolean result = super.preTemplateProcess(request, response, template, templateModel);
SimpleHash hash = (SimpleHash) templateModel;
HTMLPage htmlPage = (HTMLPage) request.getAttribute(RequestConstants.PAGE);
String title, body, head;
if (htmlPage == null) {
title = "No Title";
body = "No Body";
head = "<!-- No head -->";
} else {
title = htmlPage.getTitle();
StringWriter buffer = new StringWriter();
htmlPage.writeBody(buffer);
body = buffer.toString();
buffer = new StringWriter();
htmlPage.writeHead(buffer);
head = buffer.toString();
hash.put("page", htmlPage);
}
hash.put("title", title);
hash.put("body", body);
hash.put("head", head);
hash.put("base", request.getContextPath());
/*
Factory factory = Factory.getInstance(new Config(getServletConfig()));
Decorator decorator = factory.getDecoratorMapper().getDecorator(request, htmlPage);
-> decorator.getPage()