1packageorg.apache.jetspeed.services.jsp.tags;
23/*4 * Copyright 2000-2001,2004 The Apache Software Foundation.5 * 6 * Licensed under the Apache License, Version 2.0 (the "License");7 * you may not use this file except in compliance with the License.8 * You may obtain a copy of the License at9 * 10 * http://www.apache.org/licenses/LICENSE-2.011 * 12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */1819import javax.servlet.jsp.JspException;
20import javax.servlet.jsp.PageContext;
21import javax.servlet.jsp.tagext.TagSupport;
2223// Turbine Classes 24import org.apache.turbine.util.RunData;
25import org.apache.turbine.util.DynamicURI;
26import org.apache.turbine.util.template.TemplateLink;
27import org.apache.turbine.services.jsp.JspService;
2829// Jetspeed classes30import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
31import org.apache.jetspeed.services.logging.JetspeedLogger;
3233/***34 * Supporting class for the TemplateLink tag.35 * Uses the TemplateLink class to construct a URI36 *37 * @author <a href="mailto:ingo@raleigh.ibm.com">Ingo Schuster</a>38 */39publicclassTemplateLinkTagextends TagSupport
40 {
41/***42 * Static initialization of the logger for this class43 */44privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(TemplateLinkTag.class.getName());
4546/***47 * template parameter defines the template to set48 * mandatory parameter49 */50private String template;
5152/*** 53 * The setter for template parameter54 */55publicvoid setTemplate(String template)
56 {
57this.template = template;
58 }
5960/***61 * action parameter defines the action to set62 * optional parameter63 */64private String action;
6566/*** 67 * The setter for screen parameter68 */69publicvoid setAction(String action)
70 {
71this.action = action;
72 }
7374publicint doStartTag() throws JspException
75 {
76 RunData data = (RunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
7778 TemplateLink link = new TemplateLink( data );
79 DynamicURI uri = link.setPage( template );
80if ( action != null ) uri = uri.setAction( action );
8182try83 {
84if (uri != null) {
85 pageContext.getOut().print(uri.toString());
86 }
87 }
88catch (Exception e)
89 {
90 String message = "Error processing TemplateLink-tag, parameter: template='"+ template + "', action='" +action +"'";
91 logger.error(message, e);
92try93 {
94 data.getOut().print( message );
95 }
96catch(java.io.IOException ioe) {}
97 }
9899return EVAL_BODY_INCLUDE;
100 }
101102 }