1 package org.apache.turbine.util.template; 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.modules.NavigationLoader; 25 26 import org.apache.turbine.services.template.TurbineTemplate; 27 28 import org.apache.turbine.util.RunData; 29 30 44 public class TemplateNavigation 45 { 46 47 private static Log log = LogFactory.getLog(TemplateNavigation.class); 48 49 50 private RunData data; 51 52 53 private String template = null; 54 55 60 public TemplateNavigation(RunData data) 61 { 62 this.data = data; 63 } 64 65 72 public TemplateNavigation setTemplate(String template) 73 { 74 log.debug("setTemplate(" + template + ")"); 75 this.template = template; 76 return this; 77 } 78 79 84 public String toString() 85 { 86 String module = null; 87 String returnValue = null; 88 89 try 90 { 91 if (template == null) 92 { 93 returnValue = "Navigation Template is null (Might be unset)"; 94 throw new Exception (returnValue); 95 } 96 97 data.getTemplateInfo().setNavigationTemplate(template); 98 module = TurbineTemplate.getNavigationName(template); 99 100 if (module == null) 101 { 102 returnValue = "Template Service returned null for Navigation Template " + template; 103 throw new Exception (returnValue); 104 } 105 106 ConcreteElement results = 107 NavigationLoader.getInstance().eval(data, module); 108 returnValue = results.toString(); 109 } 110 catch (Exception e) 111 { 112 if (returnValue == null) 113 { 114 returnValue = "Error processing navigation template: " 115 + template + ", using module: " + module; 116 } 117 log.error(returnValue, e); 118 } 119 120 return returnValue; 121 } 122 } 123 | Popular Tags |