📄 cmsxmlformtemplatefile.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/defaults/CmsXmlFormTemplateFile.java,v $
* Date : $Date: 2001/07/31 15:50:13 $
* Version: $Revision: 1.8 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001 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.defaults;
import com.opencms.file.*;
import com.opencms.core.*;
import com.opencms.template.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import java.util.*;
import java.lang.reflect.*;
/**
* Template content definition for generating HTML forms.
* This is an extension of the default template content definition.
* Special tags for handling HTML form elements are added here.
* See the handleXxxTag Methods for more details.
*
* @author Alexander Lucas
* @version $Revision: 1.8 $ $Date: 2001/07/31 15:50:13 $
*/
public class CmsXmlFormTemplateFile extends CmsXmlTemplateFile implements I_CmsLogChannels {
/** Name of the select box */
public static final String C_SELECTBOX_NAME = "name";
/** Size of the select box */
public static final String C_SELECTBOX_SIZE = "size";
/** Div flag of the select box */
public static final String C_SELECTBOX_DIV = "div";
/** Stylesheet class string of the select box */
public static final String C_SELECTBOX_CLASS = "class";
/** Stylesheet class name of the select box */
public static final String C_SELECTBOX_CLASSNAME = "classname";
/** Stylesheet class name of the select box */
public static final String C_SELECTBOX_WIDTHNAME = "widthname";
/** Width of the select box */
public static final String C_SELECTBOX_WIDTH = "width";
/** Onchange of the select box */
public static final String C_SELECTBOX_ONCHANGE = "onchange";
/** Method of the select box */
public static final String C_SELECTBOX_METHOD = "method";
/** option name of the select box */
public static final String C_SELECTBOX_OPTIONNAME = "name";
/** option value of the select box */
public static final String C_SELECTBOX_OPTIONVALUE = "value";
// Parameters for radiobuttons
/** Name of the radio buttons */
public static final String C_RADIO_RADIONAME = "radioname";
/** Name of the radio button value */
public static final String C_RADIO_NAME = "name";
/** Name of the radio button link */
public static final String C_RADIO_LINK = "link";
/** Stylesheet class string of the radio button */
public static final String C_RADIO_CLASS = "class";
/** Stylesheet class name of the radio button */
public static final String C_RADIO_CLASSNAME = "classname";
/** Datablock conatining the "checked" option*/
public static final String C_RADIO_SELECTEDOPTION = "optionalselected";
/** Datablock conatining the optional entry for the "checked" option */
public static final String C_RADIO_SELECTEDENTRY = "selectedentry";
/** Method of the radio buttons */
public static final String C_RADIO_METHOD = "method";
/** Name of the radio ordering information */
public static final String C_RADIO_ORDER = "order";
/** Name of the select start tag in the input definiton template */
public static final String C_TAG_SELECTBOX_START = "selectbox.start";
/** Name of the select div start tag in the input definiton template */
public static final String C_TAG_SELECTBOX_START_DIV = "selectbox.startdiv";
/** Name of the select end tag in the input definiton template */
public static final String C_TAG_SELECTBOX_END = "selectbox.end";
/** Name of the selectbox "class" option tag in the input definiton template */
public static final String C_TAG_SELECTBOX_CLASS = "selectbox.class";
/** Name of the selectbox "width" option tag in the input definiton template */
public static final String C_TAG_SELECTBOX_WIDTH = "selectbox.width";
/** Name of the (select) option tag in the input definiton template */
public static final String C_TAG_SELECTBOX_OPTION = "selectbox.option";
/** Name of the (select) selected option tag in the input definiton template */
public static final String C_TAG_SELECTBOX_SELOPTION = "selectbox.seloption";
/** Name of the radio "class" option tag in the input definiton template */
public static final String C_TAG_RADIO_CLASS = "radiobuttons.class";
/** Name of the radion column entry tag in the input definiton template */
public static final String C_TAG_RADIO_COLENTRY = "radiobuttons.colentry";
/** Name of the radion row entry tag in the input definiton template */
public static final String C_TAG_RADIO_ROWENTRY = "radiobuttons.rowentry";
/**
* Default constructor.
*/
public CmsXmlFormTemplateFile() throws CmsException {
super();
registerMyTags();
}
/**
* Constructor for creating a new object containing the content
* of the given filename.
*
* @param cms CmsObject object for accessing system resources.
* @param filename Name of the body file that shoul be read.
*/
public CmsXmlFormTemplateFile(CmsObject cms, CmsFile file) throws CmsException {
super();
registerMyTags();
init(cms, file);
}
/**
* Constructor for creating a new object containing the content
* of the given filename.
*
* @param cms CmsObject object for accessing system resources.
* @param filename Name of the body file that shoul be read.
*/
public CmsXmlFormTemplateFile(CmsObject cms, String filename) throws CmsException {
super();
registerMyTags();
init(cms, filename);
}
/**
* Gets the expected tagname for the XML documents of this content type
* @return Expected XML tagname.
*/
public String getXmlDocumentTagName() {
return "XMLTEMPLATE";
}
/**
* Handles any occurence of the special XML tag <code><RADIOBUTTON></code> for
* generating HTML form radio buttons.
* <P>
* The definition of a HTML radio button will be taken from /content/internal/HTMLFormDefs.
* If the file is missing, this method will crash. Ensure this file is created and filled
* with all required XML tags.
* <P>
* Radio buttons can be generated by adding the special XML tag
* <code><RADIOBUTTON class="myClass" method="myMethod" name="myName"/></code>
* to the template file. This tag will be replaced with the correspondig group of radio buttons
* while processing the template file. The <code>class</code> parameter is optional.
* The <code>method</code> parameter will be used to look up a user defined method
* in the template class assigned to the template file. This method should look like
* <br/>
* <code>public Integer myMethod(CmsObject cms, Vector names, Vector values, Hashtable parameters)</code><br/>
* and will be used to get the content of the requested radion button group. The vectors <code>names</code>
* and <code>values</code> should be filled with the appropriate values. The return value should be an
* Integer containing the pre-selected radio button or -1, if no value should be pre-selected.
*
* @param n XML element containing the current special workplace tag.
* @param callingObject reference to the calling object.
* @param userObj hashtable containig all user parameters.
* @exception CmsException
*/
public Object handleRadiobuttonTag(Element n, Object callingObject, Object userObj) throws CmsException {
Hashtable parameters = (Hashtable)userObj;
// StringBuffer for the generated output
StringBuffer result = new StringBuffer();
// Here the different select box options will be stored
Vector values = new Vector();
Vector names = new Vector();
Integer returnObject = null;
// Read radiobutton parameters
String radioClass = n.getAttribute(C_SELECTBOX_CLASS);
String radioName = n.getAttribute(C_RADIO_NAME);
String radioMethod = n.getAttribute(C_RADIO_METHOD);
String radioOrder = n.getAttribute(C_RADIO_ORDER);
if(radioOrder == null || ((!"row".equals(radioOrder)) && (!"col".equals(radioOrder)))) {
radioOrder = "col";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -