1 package org.apache.turbine.services.jsp.tags; 2 3 18 19 import java.io.IOException ; 20 import javax.servlet.jsp.JspException ; 21 import javax.servlet.jsp.PageContext ; 22 import javax.servlet.jsp.tagext.TagSupport ; 23 import org.apache.turbine.services.jsp.JspService; 24 import org.apache.turbine.util.DynamicURI; 25 import org.apache.turbine.util.Log; 26 import org.apache.turbine.util.RunData; 27 import org.apache.turbine.util.template.TemplateLink; 28 29 36 public class TemplateLinkTag extends TagSupport 37 { 38 42 private String template; 43 44 47 public void setTemplate(String template) 48 { 49 this.template = template; 50 } 51 52 56 private String action; 57 58 61 public void setAction(String action) 62 { 63 this.action = action; 64 } 65 66 public int doStartTag() throws JspException 67 { 68 RunData data = 69 (RunData)pageContext.getAttribute(JspService.RUNDATA, 70 PageContext.REQUEST_SCOPE); 71 72 TemplateLink link = new TemplateLink( data ); 73 DynamicURI uri = link.setPage( template ); 74 if ( action != null ) uri = uri.setAction( action ); 75 76 try 77 { 78 if (uri != null) { 79 pageContext.getOut().print(uri.toString()); 80 } 81 } 82 catch (Exception e) 83 { 84 String message = 85 "Error processing TemplateLink-tag, parameter: template='" 86 + template + "', action='" +action +"'"; 87 Log.error(message, e); 88 try 89 { 90 data.getOut().print( message ); 91 } 92 catch(java.io.IOException ioe) {} 93 } 94 95 return EVAL_BODY_INCLUDE; 96 } 97 98 } 99 100 | Popular Tags |