1 package org.apache.turbine.modules.layouts; 2 3 18 19 import java.io.StringReader ; 20 21 import org.apache.commons.logging.Log; 22 import org.apache.commons.logging.LogFactory; 23 24 import org.apache.ecs.ConcreteElement; 25 26 import org.apache.turbine.TurbineConstants; 27 import org.apache.turbine.modules.Layout; 28 import org.apache.turbine.modules.ScreenLoader; 29 import org.apache.turbine.services.velocity.TurbineVelocity; 30 import org.apache.turbine.services.xslt.TurbineXSLT; 31 import org.apache.turbine.util.RunData; 32 import org.apache.turbine.util.template.TemplateNavigation; 33 34 import org.apache.velocity.context.Context; 35 36 55 public class VelocityXslLayout extends Layout 56 { 57 58 private static Log log = LogFactory.getLog(VelocityXslLayout.class); 59 60 61 private String prefix = TurbineConstants.LAYOUT_PREFIX + "/"; 62 63 70 public void doBuild(RunData data) 71 throws Exception 72 { 73 Context context = TurbineVelocity.getContext(data); 75 76 data.getResponse().setContentType("text/html"); 77 78 String screenName = data.getScreen(); 79 80 log.debug("Loading Screen " + screenName); 81 82 ConcreteElement results = 85 ScreenLoader.getInstance().eval(data, screenName); 86 87 String returnValue = (results == null) ? "" : results.toString(); 88 89 context.put(TurbineConstants.SCREEN_PLACEHOLDER, returnValue); 91 92 context.put(TurbineConstants.NAVIGATION_PLACEHOLDER, 94 new TemplateNavigation(data)); 95 96 String templateName = data.getTemplateInfo().getLayoutTemplate(); 100 101 log.debug("Now trying to render layout " + templateName); 102 103 String temp = TurbineVelocity.handleRequest(context, 105 prefix + templateName); 106 107 TurbineXSLT.transform( 110 data.getTemplateInfo().getScreenTemplate(), 111 new StringReader (temp), data.getOut()); 112 } 113 } 114 | Popular Tags |