1 13 package info.magnolia.module.admininterface; 14 15 import info.magnolia.cms.util.FreeMarkerUtil; 16 17 import java.io.IOException ; 18 import java.io.PrintWriter ; 19 import java.util.HashMap ; 20 import java.util.Map ; 21 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.http.HttpServletResponse ; 24 25 26 32 public class TemplatedMVCHandler extends PageMVCHandler { 33 34 39 public TemplatedMVCHandler(String name, HttpServletRequest request, HttpServletResponse response) { 40 super(name, request, response); 41 } 42 43 48 protected String getTemplateName(String viewName) { 49 return FreeMarkerUtil.createTemplateName(this.getClass(), "html"); 50 } 51 52 55 public void renderHtml(String view) throws IOException { 56 57 String template = this.getTemplateName(view); 58 if (template != null) { 59 60 Map data = new HashMap (); 61 data.put("this", this); 62 63 PrintWriter writer; 64 65 try { 66 writer = getResponse().getWriter(); 67 } 68 catch (IllegalStateException e) { 69 writer = new PrintWriter (getResponse().getOutputStream()); 71 } 72 FreeMarkerUtil.process(template, data, writer); 73 } 74 } 75 76 } 77 | Popular Tags |