KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > services > jsp > tags > DynamicURITag


1 package org.apache.jetspeed.services.jsp.tags;
2
3 /*
4  * Copyright 2000-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 at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * 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 and
16  * limitations under the License.
17  */

18
19 import javax.servlet.jsp.JspException JavaDoc;
20 import javax.servlet.jsp.PageContext JavaDoc;
21 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
22
23 // Turbine Classes
24
import org.apache.turbine.util.RunData;
25 import org.apache.turbine.util.template.TemplateLink;
26 import org.apache.turbine.services.jsp.JspService;
27
28 // Jetspeed classes
29
import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
30 import org.apache.jetspeed.services.logging.JetspeedLogger;
31
32 /**
33  * Supporting class for the DynamicURI tag.
34  * Basically routes the call to DynamicUri
35  *
36  * @author <a HREF="mailto:ingo@raleigh.ibm.com">Ingo Schuster</a>
37  * @version $Id: DynamicURITag.java,v 1.11 2004/02/23 03:59:40 jford Exp $
38  */

39 public class DynamicURITag extends TagSupport JavaDoc
40 {
41     /**
42      * Static initialization of the logger for this class
43      */

44     private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(DynamicURITag.class.getName());
45     
46     /**
47      * screen parameter defines the screen to set
48      */

49     private String JavaDoc screen;
50
51     /**
52      * The setter for screen parameter
53      */

54     public void setScreen(String JavaDoc screen)
55     {
56         this.screen = screen;
57     }
58
59     /**
60      * screen parameter defines the screen to set
61      */

62     private String JavaDoc template;
63
64     /**
65      * The setter for screen parameter
66      */

67     public void setTemplate(String JavaDoc template)
68     {
69         this.template = template;
70     }
71
72     /**
73      * action parameter defines the action to set
74      */

75     private String JavaDoc action;
76
77     /**
78      * The setter for screen parameter
79      */

80     public void setAction(String JavaDoc action)
81     {
82         this.action = action;
83     }
84
85     public int doStartTag() throws JspException JavaDoc
86     {
87         RunData data = (RunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
88         
89         TemplateLink uri = new TemplateLink( data );
90         if ( template != null ) uri.setPage( template );
91         if ( screen != null ) uri.setScreen( screen );
92         if ( action != null ) uri.setAction( action );
93
94         try
95         {
96             if (uri != null) {
97                 pageContext.getOut().print(uri.toString());
98             }
99         }
100         catch (Exception JavaDoc e)
101         {
102             String JavaDoc message = "Error processing DynamicUriTag, parameter: screen='"+ screen + "', action='" +action +"'";
103             logger.error(message, e);
104             try
105             {
106                 data.getOut().print( message );
107             }
108             catch(java.io.IOException JavaDoc ioe) {}
109         }
110        
111         return EVAL_BODY_INCLUDE;
112     }
113
114 }
115
Popular Tags