1 package org.apache.turbine.modules.layouts; 2 3 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 22 import org.apache.ecs.ConcreteElement; 23 24 import org.apache.turbine.TurbineConstants; 25 import org.apache.turbine.modules.Layout; 26 import org.apache.turbine.modules.ScreenLoader; 27 import org.apache.turbine.services.velocity.TurbineVelocity; 28 import org.apache.turbine.util.RunData; 29 import org.apache.turbine.util.template.TemplateNavigation; 30 31 import org.apache.velocity.context.Context; 32 33 64 public class VelocityOnlyLayout 65 extends Layout 66 { 67 68 private static Log log = LogFactory.getLog(VelocityOnlyLayout.class); 69 70 71 private String prefix = TurbineConstants.LAYOUT_PREFIX + "/"; 72 73 80 public void doBuild(RunData data) 81 throws Exception 82 { 83 Context context = TurbineVelocity.getContext(data); 85 86 String screenName = data.getScreen(); 87 88 log.debug("Loading Screen " + screenName); 89 90 ConcreteElement results = 93 ScreenLoader.getInstance().eval(data, screenName); 94 95 String returnValue = (results == null) ? "" : results.toString(); 96 97 context.put(TurbineConstants.SCREEN_PLACEHOLDER, returnValue); 99 100 context.put(TurbineConstants.NAVIGATION_PLACEHOLDER, 102 new TemplateNavigation(data)); 103 104 String templateName = data.getTemplateInfo().getLayoutTemplate(); 108 109 data.getResponse().setLocale(data.getLocale()); 111 data.getResponse().setContentType(data.getContentType()); 112 113 log.debug("Now trying to render layout " + templateName); 114 115 data.getOut().print(TurbineVelocity 117 .handleRequest(context, prefix + templateName)); 118 } 119 } 120 | Popular Tags |