001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/widgets/CmsTextareaWidget.java,v $
003: * Date : $Date: 2008-02-27 12:05:43 $
004: * Version: $Revision: 1.15 $
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 textarea widget, for use on a widget dialog.<p>
039: *
040: * Displays a textarea with 4 rows to enter String values conveniently.<p>
041: *
042: * @author Andreas Zahner
043: *
044: * @version $Revision: 1.15 $
045: *
046: * @since 6.0.0
047: */
048: public class CmsTextareaWidget extends A_CmsWidget {
049:
050: /** Default number of rows to display. */
051: private static final int DEFAULT_ROWS_NUMBER = 4;
052:
053: /**
054: * Creates a new textarea widget.<p>
055: */
056: public CmsTextareaWidget() {
057:
058: // default configuration is to display 4 rows
059: this (DEFAULT_ROWS_NUMBER);
060: }
061:
062: /**
063: * Creates a new textarea widget with the given number of rows.<p>
064: *
065: * @param rows the number of rows to display
066: */
067: public CmsTextareaWidget(int rows) {
068:
069: super ("" + rows);
070: }
071:
072: /**
073: * Creates a new textarea widget with the given configuration.<p>
074: *
075: * @param configuration the configuration to use
076: */
077: public CmsTextareaWidget(String configuration) {
078:
079: super (configuration);
080: }
081:
082: /**
083: * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter)
084: */
085: public String getDialogWidget(CmsObject cms,
086: I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) {
087:
088: String id = param.getId();
089: StringBuffer result = new StringBuffer(16);
090: int rows = DEFAULT_ROWS_NUMBER;
091: try {
092: rows = new Integer(getConfiguration()).intValue();
093: } catch (Exception e) {
094: // ignore
095: }
096:
097: result.append("<td class=\"xmlTd\">");
098: result.append("<textarea class=\"xmlInput maxwidth");
099: if (param.hasError()) {
100: result.append(" xmlInputError");
101: }
102: result.append("\" name=\"");
103: result.append(id);
104: result.append("\" rows=\"");
105: result.append(rows);
106: result.append("\" cols=\"60\" style=\"overflow:auto;\">");
107: result.append(CmsEncoder.escapeXml(param.getStringValue(cms)));
108: result.append("</textarea>");
109: result.append("</td>");
110:
111: return result.toString();
112: }
113:
114: /**
115: * @see org.opencms.widgets.I_CmsWidget#newInstance()
116: */
117: public I_CmsWidget newInstance() {
118:
119: return new CmsTextareaWidget(getConfiguration());
120: }
121:
122: }
|