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 47 public class VelocityECSLayout 48 extends Layout 49 { 50 51 private static Log log = LogFactory.getLog(VelocityECSLayout.class); 52 53 54 private String prefix = TurbineConstants.LAYOUT_PREFIX + "/"; 55 56 57 private static boolean hasWarned = false; 58 59 62 public VelocityECSLayout() 63 { 64 if (!hasWarned) 65 { 66 log.warn("The VelocityECSLayout is deprecated. " 67 + "Please switch to VelocityOnlyLayout."); 68 hasWarned = true; 69 } 70 } 71 72 79 public void doBuild(RunData data) 80 throws Exception 81 { 82 Context context = TurbineVelocity.getContext(data); 84 85 String screenName = data.getScreen(); 86 87 log.debug("Loading Screen " + screenName); 88 89 ConcreteElement results = 92 ScreenLoader.getInstance().eval(data, screenName); 93 94 String returnValue = (results == null) ? "" : results.toString(); 95 96 context.put(TurbineConstants.SCREEN_PLACEHOLDER, returnValue); 98 99 context.put(TurbineConstants.NAVIGATION_PLACEHOLDER, 101 new TemplateNavigation(data)); 102 103 String templateName = data.getTemplateInfo().getLayoutTemplate(); 107 108 log.debug("Now trying to render layout " + templateName); 109 110 data.getPage().getBody().addElement(TurbineVelocity 113 .handleRequest(context, prefix + templateName)); 114 } 115 } 116 | Popular Tags |