1 package org.apache.jetspeed.services.jsp.tags; 2 3 18 19 import javax.servlet.jsp.JspException ; 20 import javax.servlet.jsp.PageContext ; 21 import javax.servlet.jsp.tagext.TagSupport ; 22 23 import org.apache.turbine.util.RunData; 25 import org.apache.turbine.util.DynamicURI; 26 import org.apache.turbine.util.template.TemplateLink; 27 import org.apache.turbine.services.jsp.JspService; 28 29 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService; 31 import org.apache.jetspeed.services.logging.JetspeedLogger; 32 33 39 public class TemplateLinkTag extends TagSupport 40 { 41 44 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(TemplateLinkTag.class.getName()); 45 46 50 private String template; 51 52 55 public void setTemplate(String template) 56 { 57 this.template = template; 58 } 59 60 64 private String action; 65 66 69 public void setAction(String action) 70 { 71 this.action = action; 72 } 73 74 public int doStartTag() throws JspException 75 { 76 RunData data = (RunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE); 77 78 TemplateLink link = new TemplateLink( data ); 79 DynamicURI uri = link.setPage( template ); 80 if ( action != null ) uri = uri.setAction( action ); 81 82 try 83 { 84 if (uri != null) { 85 pageContext.getOut().print(uri.toString()); 86 } 87 } 88 catch (Exception e) 89 { 90 String message = "Error processing TemplateLink-tag, parameter: template='"+ template + "', action='" +action +"'"; 91 logger.error(message, e); 92 try 93 { 94 data.getOut().print( message ); 95 } 96 catch(java.io.IOException ioe) {} 97 } 98 99 return EVAL_BODY_INCLUDE; 100 } 101 102 } 103 | Popular Tags |