📄 cmsjsptagfileproperty.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/flex/jsp/Attic/CmsJspTagFileProperty.java,v $
* Date : $Date: 2002/05/10 21:07:30 $
* Version: $Revision: 1.1.2.1.2.1 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2002 The OpenCms Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about OpenCms, please see the
* OpenCms Website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.opencms.flex.jsp;
/**
* This Tag provides access to the currently included files OpenCms properties.
*
* @author Alexander Kandzior (a.kandzior@alkacon.com)
* @version $Revision: 1.1.2.1.2.1 $
*/
public class CmsJspTagFileProperty extends javax.servlet.jsp.tagext.TagSupport implements I_CmsJspConstants {
private String m_propertyName = null;
private String m_propertyFile = null;
public void setName(String name) {
if (name != null) {
m_propertyName = name.toLowerCase();
}
}
public String getName() {
return m_propertyName!=null?m_propertyName:"";
}
public void setFile(String file) {
if (file != null) {
m_propertyFile = file.toLowerCase();
}
}
public String getFile() {
return m_propertyFile!=null?m_propertyFile:"parent";
}
public void release() {
super.release();
m_propertyFile = null;
m_propertyName = null;
}
public int doStartTag() throws javax.servlet.jsp.JspException {
javax.servlet.ServletRequest req = pageContext.getRequest();
javax.servlet.ServletResponse res = pageContext.getResponse();
// This will always be true if the page is called through OpenCms
if ((req instanceof com.opencms.flex.cache.CmsFlexRequest) &&
(res instanceof com.opencms.flex.cache.CmsFlexResponse)) {
com.opencms.flex.cache.CmsFlexRequest c_req = (com.opencms.flex.cache.CmsFlexRequest)req;
com.opencms.flex.cache.CmsFlexResponse c_res = (com.opencms.flex.cache.CmsFlexResponse)res;
try {
com.opencms.file.CmsObject cms = c_req.getCmsObject();
javax.servlet.jsp.JspWriter out = pageContext.getOut();
java.util.Hashtable props = null;
String file = null;
if ("parent".equals(getFile())) {
// Read properties of parent (i.e. top requested) file
file = c_req.getCmsFile().getAbsolutePath();
} else if ("this".equals(getFile())) {
// Read properties of this file
file = c_req.getCmsResource();
} else {
// Read properties of the file named in the attribute
file = c_req.toAbsolute(getFile());
}
// cms.readProperty(file, getName());
out.print(cms.readProperty(file, getName()));
/*
// Aqquire a hashtable with all file properties
// This is saved in the page context so that the database is not accessed more then once per page
Object o = pageContext.getAttribute(this.C_JSP_ATTR_TAGFILEPROPERTY);
if (o == null ) {
// Properties have not been loaded, so read them from the DB
java.util.Hashtable dbprops = cms.readAllProperties(c_req.getCmsResource());
// Make all keys in the hashtable lower case and stor this in a new hashtable
props = new java.util.Hashtable(dbprops.size());
java.util.Enumeration e = dbprops.keys();
while (e.hasMoreElements()) {
String key = (String)e.nextElement();
props.put(key.toLowerCase(), dbprops.get(key));
}
// Save property hashtable in page context
pageContext.setAttribute(this.C_JSP_ATTR_TAGFILEPROPERTY, props);
} else {
// Properties have already been loaded, just reuse them
props = (java.util.Hashtable)o;
}
if (m_propertyName == null) {
// If no property selectet a list of all properties is returned
java.util.Enumeration e = props.keys();
while (e.hasMoreElements()) {
String key = (String)e.nextElement();
out.print(key + "=" + props.get(key) + "; ");
}
} else {
// Return value of selected property
out.print(props.get(m_propertyName));
}
*/
} catch (Exception ex) {
System.err.println("Error in Jsp 'property' tag processing: " + ex);
System.err.println(com.opencms.util.Utils.getStackTrace(ex));
throw new javax.servlet.jsp.JspException(ex);
}
}
return SKIP_BODY;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -