KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > frontend > templateone > CmsTemplateBase


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/frontend/templateone/CmsTemplateBase.java,v $
3  * Date : $Date: 2006/03/27 14:52:51 $
4  * Version: $Revision: 1.3 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (C) 2005 Alkacon Software GmbH (http://www.alkacon.com)
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 Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.frontend.templateone;
33
34 import org.opencms.jsp.CmsJspActionElement;
35 import org.opencms.util.CmsStringUtil;
36
37 import javax.servlet.http.HttpServletRequest JavaDoc;
38 import javax.servlet.http.HttpServletResponse JavaDoc;
39 import javax.servlet.jsp.PageContext JavaDoc;
40
41 /**
42  * Base action element for all template one beans.<p>
43  *
44  * @author Alexander Kandzior
45  *
46  * @version $Revision: 1.3 $
47  *
48  * @since 6.1.0
49  */

50 public class CmsTemplateBase extends CmsJspActionElement {
51
52     /** The old uri is stored in this parameter (if required). */
53     public static final String JavaDoc ATTRIBUTE_ORIGINAL_URI = "__originalOpenCmsUri";
54
55     /**
56      * Empty constructor, required for every JavaBean.<p>
57      */

58     public CmsTemplateBase() {
59
60         super();
61     }
62
63     /**
64      * @see CmsJspActionElement#CmsJspActionElement(PageContext, HttpServletRequest, HttpServletResponse)
65      */

66     public CmsTemplateBase(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
67
68         super(context, req, res);
69     }
70
71     /**
72      * Returns the original OpenCms request context URI thas has been changed, or <code>null</code>
73      * if the URI was not changed.<p>
74      *
75      * @return the original OpenCms request context URI thas has been changed, or <code>null</code>
76      * if the URI was not changed
77      */

78     public String JavaDoc getOriginalUri() {
79
80         return (String JavaDoc)getRequest().getAttribute(ATTRIBUTE_ORIGINAL_URI);
81     }
82
83     /**
84      * Initializes the URI of the current template page.<p>
85      *
86      * This checks for the presence of a special <code>uri</code> parameter.
87      * If this parameter is found, the OpenCms request context URI is switched to this value.<p>
88      */

89     public void initUri() {
90
91         String JavaDoc uri = getRequest().getParameter(CmsTemplateBean.PARAM_URI);
92         if (CmsStringUtil.isNotEmpty(uri)) {
93             getRequest().setAttribute(ATTRIBUTE_ORIGINAL_URI, getRequestContext().getUri());
94             getRequestContext().setUri(uri);
95         }
96     }
97
98     /**
99      * Returns <code>true</code> if the OpenCms request context URI has been changed.<p>
100      *
101      * @return <code>true</code> if the OpenCms request context URI has been changed
102      */

103     public boolean isUriChanged() {
104
105         return null != getOriginalUri();
106     }
107 }
Popular Tags