1 package org.apache.turbine.modules.screens; 2 3 18 19 import org.apache.commons.lang.StringUtils; 20 import org.apache.commons.lang.exception.ExceptionUtils; 21 22 import org.apache.ecs.ConcreteElement; 23 24 import org.apache.velocity.context.Context; 25 26 import org.apache.turbine.Turbine; 27 import org.apache.turbine.TurbineConstants; 28 import org.apache.turbine.services.template.TurbineTemplate; 29 import org.apache.turbine.services.velocity.TurbineVelocity; 30 import org.apache.turbine.util.RunData; 31 32 42 public class VelocityDirectScreen 43 extends VelocityScreen 44 { 45 46 private String prefix = TurbineConstants.SCREEN_PREFIX + "/"; 47 48 55 public ConcreteElement buildTemplate(RunData data) 56 throws Exception 57 { 58 Context context = TurbineVelocity.getContext(data); 59 60 String screenTemplate = data.getTemplateInfo().getScreenTemplate(); 61 String templateName 62 = TurbineTemplate.getScreenTemplateName(screenTemplate); 63 64 if (StringUtils.isEmpty(templateName)) 66 { 67 log.error("Screen " + screenTemplate + " not found!"); 68 throw new Exception ("Could not find screen for " + screenTemplate); 69 } 70 71 try 72 { 73 TurbineVelocity.handleRequest(context, 74 prefix + templateName, 75 data.getOut()); 76 77 } 78 catch (Exception e) 79 { 80 context.put (TurbineConstants.PROCESSING_EXCEPTION_PLACEHOLDER, e.toString()); 84 context.put (TurbineConstants.STACK_TRACE_PLACEHOLDER, ExceptionUtils.getStackTrace(e)); 85 86 templateName = Turbine.getConfiguration() 87 .getString(TurbineConstants.TEMPLATE_ERROR_KEY, 88 TurbineConstants.TEMPLATE_ERROR_VM); 89 90 TurbineVelocity.handleRequest(context, 91 prefix + templateName, 92 data.getOut()); 93 } 94 95 return null; 96 } 97 } 98 | Popular Tags |