View Javadoc

1   /*
2    * $Id: DefinitionTagSupport.java 421151 2006-07-12 06:07:14Z wsmoak $
3    *
4    * Copyright 1999-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  package org.apache.struts.tiles.taglib;
19  
20  import java.io.Serializable;
21  import javax.servlet.jsp.tagext.TagSupport;
22  
23  /***
24   * Common base class for tags dealing with Tiles definitions.
25   * This class defines properties used in Definition Tags.
26   * It also extends TagSupport.
27   */
28  public class DefinitionTagSupport extends TagSupport implements Serializable {
29      /***
30       * Associated Controller type
31       */
32      protected String controllerType;
33      /***
34       * Associated Controller name (classname or url)
35       */
36      protected String controllerName;
37      /***
38       * Role associated to definition.
39       */
40      protected String role;
41      /***
42       * Uri of page assoicated to this definition.
43       */
44      protected String page;
45  
46      /***
47       * Release class properties.
48       */
49      public void release() {
50          super.release();
51          controllerType = null;
52          controllerName = null;
53          role = null;
54          page = null;
55      }
56  
57      /***
58       * Get controller type.
59       * Type can be 'classname', 'url'.
60       *
61       * @return Controller type.
62       */
63      public String getControllerType() {
64          return controllerType;
65      }
66  
67      /***
68       * Get controller name.
69       * Name denotes a fully qualified classname, or an url.
70       * Exact type can be specified with {@link #setControllerType}.
71       *
72       * @return Controller name.
73       */
74      public String getControllerName() {
75          return controllerName;
76      }
77  
78      /***
79       * Set associated controller type.
80       * Type denotes a fully qualified classname.
81       *
82       * @param controllerType Type of associated controller.
83       */
84      public void setControllerType(String controllerType) {
85          this.controllerType = controllerType;
86      }
87  
88      /***
89       * Set associated controller name.
90       * Name denotes a fully qualified classname, or an url.
91       * Exact type can be specified with {@link #setControllerType}.
92       *
93       * @param controller Controller classname or url.
94       */
95      public void setController(String controller) {
96          setControllerName(controller);
97      }
98  
99      /***
100      * Set associated controller name.
101      * Name denote a fully qualified classname, or an url.
102      * Exact type can be specified with setControllerType.
103      *
104      * @param controller Controller classname or url
105      */
106     public void setControllerName(String controller) {
107         this.controllerName = controller;
108     }
109 
110     /***
111      * Set associated controller name as an url, and controller
112      * type as "url".
113      * Name must be an url (not checked).
114      * Convenience method.
115      *
116      * @param controller Controller url
117      */
118     public void setControllerUrl(String controller) {
119         setControllerName(controller);
120         setControllerType("url");
121     }
122 
123     /***
124      * Set associated controller name as a classtype and controller
125      * type as "classname".
126      * Name denotes a fully qualified classname.
127      * Convenience method.
128      *
129      * @param controller Controller classname.
130      */
131     public void setControllerClass(String controller) {
132         setControllerName(controller);
133         setControllerType("classname");
134     }
135 
136     /***
137      * Get associated role.
138      *
139      * @return Associated role.
140      */
141     public String getRole() {
142         return role;
143     }
144 
145     /***
146      * Set associated role.
147      *
148      * @param role Associated role.
149      */
150     public void setRole(String role) {
151         this.role = role;
152     }
153 
154     /***
155      * Set the page.
156      *
157      * @param page Page.
158      */
159     public void setPage(String page) {
160         this.page = page;
161     }
162 
163     /***
164      * Get the page.
165      *
166      * @return Page.
167      */
168     public String getPage() {
169         return page;
170     }
171 
172     /***
173      * Get the template.
174      * Same as getPage().
175      *
176      * @return Template.
177      */
178     public String getTemplate() {
179         return page;
180     }
181 
182     /***
183      * Set the template.
184      * Same as setPage().
185      *
186      * @param template Template.
187      */
188     public void setTemplate(String template) {
189         this.page = template;
190     }
191 }