KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > template > CmsJavascriptTemplate


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/template/CmsJavascriptTemplate.java,v $
3 * Date : $Date: 2005/05/17 13:47:32 $
4 * Version: $Revision: 1.1 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * For further information about OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29
30 package com.opencms.template;
31
32 import org.opencms.file.CmsObject;
33 import org.opencms.file.CmsRequestContext;
34 import org.opencms.main.CmsException;
35
36 import com.opencms.template.cache.A_CmsElement;
37
38 import java.util.Hashtable JavaDoc;
39
40 /**
41  * Represents a JavaScript template.
42  * @author Alexander Lucas
43  * @version $Revision: 1.1 $ $Date: 2005/05/17 13:47:32 $
44  *
45  * @deprecated Will not be supported past the OpenCms 6 release.
46  */

47 public class CmsJavascriptTemplate extends A_CmsTemplate implements I_CmsJavascriptTemplate {
48
49     /**
50      * Gets the content of a given template file with the given parameters.
51      * <P>
52      * Parameters are stored in a hashtable and can derive from
53      * <UL>
54      * <LI>Template file of the parent template</LI>
55      * <LI>Body file clicked by the user</LI>
56      * <LI>URL parameters</LI>
57      * </UL>
58      * Paramter names must be in "elementName.parameterName" format.
59      *
60      * @param cms CmsObject Object for accessing system resources
61      * @param templateFile Filename of the template file
62      * @param elementName Element name of this template in our parent template
63      * @param parameters Hashtable with all template class parameters.
64      * @return Content of the template and all subtemplates.
65      * @throws CmsException if something goes wrong
66      */

67     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters) throws CmsException {
68         return "".getBytes();
69     }
70
71     /**
72      * Gets the content of a defined section in a given template file
73      * with the given parameters.
74      *
75      * @see #getContent(CmsObject, String, String, Hashtable, String)
76      * @param cms CmsObject Object for accessing system resources.
77      * @param templateFile Filename of the template file.
78      * @param elementName Element name of this template in our parent template.
79      * @param parameters Hashtable with all template class parameters.
80      * @param templateSelector section that should be processed.
81      * @return Content of the template and all subtemplates.
82      * @throws CmsException if something goes wrong
83      */

84     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector) throws CmsException {
85         return "".getBytes();
86     }
87
88     /**
89      * Gets the key that should be used to cache the results of
90      * <EM>this</EM> template class. For simple template classes, e.g.
91      * classes only dumping file contents and not using parameters,
92      * the name of the template file may be adequate.
93      * Other classes have to return a more complex key.
94      *
95      * @param cms CmsObject Object for accessing system resources
96      * @param templateFile Filename of the template file
97      * @param parameters Hashtable with all template class parameters.
98      * @param templateSelector template section that should be processed.
99      * @return key that can be used for caching
100      */

101     public Object JavaDoc getKey(CmsObject cms, String JavaDoc templateFile, Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
102         CmsRequestContext reqContext = cms.getRequestContext();
103         return "" + reqContext.currentProject().getId() + ":" + reqContext.addSiteRoot(templateFile);
104     }
105
106     /**
107      * Indicates if the results of this class are cacheable.
108      * <P>
109      * Complex classes that are able top include other subtemplates
110      * have to check the cacheability of their subclasses here!
111      *
112      * @param cms CmsObject Object for accessing system resources
113      * @param templateFile Filename of the template file
114      * @param elementName Element name of this template in our parent template.
115      * @param parameters Hashtable with all template class parameters.
116      * @param templateSelector template section that should be processed.
117      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
118      */

119     /*public boolean isCacheable(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector) {
120         return true;
121     }*/

122
123     /**
124      * Indicates if the current template class is able to stream it's results
125      * directly to the response oputput stream.
126      * <P>
127      * Classes must not set this feature, if they might throw special
128      * exception that cause HTTP errors (e.g. 404/Not Found), or if they
129      * might send HTTP redirects.
130      * <p>
131      * If a class sets this feature, it has to check the
132      * isStreaming() property of the RequestContext. If this is set
133      * to <code>true</code> the results must be streamed directly
134      * to the output stream. If it is <code>false</code> the results
135      * must not be streamed.
136      * <P>
137      * Complex classes that are able top include other subtemplates
138      * have to check the streaming ability of their subclasses here!
139      *
140      * @param cms CmsObject Object for accessing system resources
141      * @param templateFile Filename of the template file
142      * @param elementName Element name of this template in our parent template.
143      * @param parameters Hashtable with all template class parameters.
144      * @param templateSelector template section that should be processed.
145      * @return <EM>true</EM> if this class may stream it's results, <EM>false</EM> otherwise.
146      */

147     public boolean isStreamable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
148         return false;
149     }
150     /**
151      * Tests, if the template cache is setted.
152      * @return <code>true</code> if setted, <code>false</code> otherwise.
153      */

154     public boolean isTemplateCacheSet() {
155         return true;
156     }
157
158     /**
159      * Set the instance of template cache that should be used to store
160      * cacheable results of the subtemplates.
161      * If the template cache is not set, caching will be disabled.
162      * @param c Template cache to be used.
163      */

164     public void setTemplateCache(I_CmsTemplateCache c) {
165         // noop
166
}
167
168     /**
169      * Indicates if a previous cached result should be reloaded.
170      *
171      * @param cms CmsObject Object for accessing system resources
172      * @param templateFile Filename of the template file
173      * @param elementName Element name of this template in our parent template.
174      * @param parameters Hashtable with all template class parameters.
175      * @param templateSelector template section that should be processed.
176      * @return <EM>true</EM> if reload is neccesary, <EM>false</EM> otherwise.
177      */

178     public boolean shouldReload(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
179         return true;
180     }
181
182     /**
183      * Not yet implemented.<p>
184      *
185      * @param cms CmsObject Object for accessing system resources
186      * @param templateFile Filename of the template file
187      * @param parameters Hashtable with all template class parameters
188      * @return the element
189      */

190     public A_CmsElement createElement(CmsObject cms, String JavaDoc templateFile, Hashtable JavaDoc parameters) {
191         // to be implemented
192
return null;
193     }
194 }
195
Popular Tags