1 24 package org.riotfamily.common.web.view.freemarker; 25 26 import java.util.Map ; 27 28 import org.riotfamily.common.web.view.MacroHelperFactory; 29 import org.springframework.web.servlet.view.AbstractUrlBasedView; 30 import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; 31 32 public class RiotFreeMarkerViewResolver extends FreeMarkerViewResolver { 33 34 private boolean allowModelOverride = true; 35 36 private boolean freeMarkerServletMode = false; 37 38 private Map macroHelperFactories; 39 40 public RiotFreeMarkerViewResolver() { 41 setExposeSpringMacroHelpers(true); 42 } 43 44 public void setAllowModelOverride(boolean allowModelOverride) { 45 this.allowModelOverride = allowModelOverride; 46 } 47 48 public void setFreeMarkerServletMode(boolean freeMarkerServletMode) { 49 this.freeMarkerServletMode = freeMarkerServletMode; 50 } 51 52 protected void initApplicationContext() { 53 super.initApplicationContext(); 54 macroHelperFactories = getApplicationContext().getBeansOfType(MacroHelperFactory.class); 55 } 56 57 protected Class requiredViewClass() { 58 return RiotFreeMarkerView.class; 59 } 60 61 protected AbstractUrlBasedView buildView(String viewName) throws Exception { 62 RiotFreeMarkerView view = (RiotFreeMarkerView) super.buildView(viewName); 63 view.setAllowModelOverride(allowModelOverride); 64 view.setFreeMarkerServletMode(freeMarkerServletMode); 65 view.setMacroHelperFactories(macroHelperFactories); 66 return view; 67 } 68 } 69 | Popular Tags |