View Javadoc

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;
20  import javax.servlet.jsp.PageContext;
21  import javax.servlet.jsp.tagext.TagSupport;
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 
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 screen;
50  
51      /*** 
52       * The setter for screen parameter
53       */
54      public void setScreen(String screen)
55      {
56          this.screen = screen;
57      }
58  
59      /***
60       * screen parameter defines the screen to set
61       */
62      private String template;
63  
64      /*** 
65       * The setter for screen parameter
66       */
67      public void setTemplate(String template)
68      {
69          this.template = template;
70      }
71  
72      /***
73       * action parameter defines the action to set
74       */
75      private String action;
76  
77      /*** 
78       * The setter for screen parameter
79       */
80      public void setAction(String action)
81      {
82          this.action = action;
83      }
84  
85      public int doStartTag() throws JspException 
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 e)
101         {
102             String 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 ioe) {}    
109         }
110        
111         return EVAL_BODY_INCLUDE;
112     }
113 
114 }