001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/widgets/CmsInputWidget.java,v $
003: * Date : $Date: 2008-02-27 12:05:44 $
004: * Version: $Revision: 1.12 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.widgets;
033:
034: import org.opencms.file.CmsObject;
035: import org.opencms.i18n.CmsEncoder;
036:
037: /**
038: * Provides a standard HTML form input widget, for use on a widget dialog.<p>
039: *
040: * @author Alexander Kandzior
041: *
042: * @version $Revision: 1.12 $
043: *
044: * @since 6.0.0
045: */
046: public class CmsInputWidget extends A_CmsWidget {
047:
048: /**
049: * Creates a new input widget.<p>
050: */
051: public CmsInputWidget() {
052:
053: // empty constructor is required for class registration
054: this ("");
055: }
056:
057: /**
058: * Creates a new input widget with the given configuration.<p>
059: *
060: * @param configuration the configuration to use
061: */
062: public CmsInputWidget(String configuration) {
063:
064: super (configuration);
065: }
066:
067: /**
068: * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter)
069: */
070: public String getDialogWidget(CmsObject cms,
071: I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) {
072:
073: String id = param.getId();
074:
075: StringBuffer result = new StringBuffer(16);
076:
077: result.append("<td class=\"xmlTd\">");
078: result.append("<input class=\"xmlInput textInput");
079: if (param.hasError()) {
080: result.append(" xmlInputError");
081: }
082: result.append("\"");
083: result.append(" name=\"");
084: result.append(id);
085: result.append("\" id=\"");
086: result.append(id);
087: result.append("\" value=\"");
088: result.append(CmsEncoder.escapeXml(param.getStringValue(cms)));
089: result.append("\">");
090: result.append("</td>");
091:
092: return result.toString();
093: }
094:
095: /**
096: * @see org.opencms.widgets.I_CmsWidget#newInstance()
097: */
098: public I_CmsWidget newInstance() {
099:
100: return new CmsInputWidget(getConfiguration());
101: }
102: }
|