KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > util > HTMLElementTextArea


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.util;
11
12 import java.util.*;
13
14 /**
15  * Generates a HTML Element: TEXTAREA.
16  * Uses this variables which are set in the
17  * super class (HTMLElement) to generate HTML:
18  * <ul>
19  * <li>boolean moreValues : if true it will take the first value of a list of items.</li>
20  * <li>Vector valuesList : The list of items. </li>
21  * <li>String cols : if not null the HTML tag COLS=cols is added </li>
22  * <li>String rows : if not null the HTML tag ROWS=rows is added </li>
23  * </ul>
24  *
25  * @application SCAN
26  * @author Jan van Oosterom
27  * @version $Id: HTMLElementTextArea.java,v 1.6 2004/09/29 14:29:25 pierre Exp $
28  */

29 public class HTMLElementTextArea extends HTMLElement {
30     // Note: more appropriate would be to extend from HTMLElementText
31

32     /**
33      * Creates a HTMLElementTextArea
34      */

35     public HTMLElementTextArea() {
36     }
37
38     /**
39      * Generates the HTML code.
40      */

41     protected String JavaDoc generate() {
42         String JavaDoc html = "";
43         if (moreValues) {
44             if (valuesList != null) {
45                 String JavaDoc val = null;
46                 Enumeration e = valuesList.elements();
47                 if (e.hasMoreElements()) {
48                     val = (String JavaDoc) e.nextElement();
49                 }
50                 html += "<textarea name=\"" + name+"\" ";
51                 if (cols != null) html += "cols=\"" + cols+"\" ";
52                 if (rows != null) html += " rows=\"" + rows+"\" ";
53                 html += ">";
54                 if (val != null) html += val;
55                 html += "</textarea>";
56             }
57         } else {
58             html += "<textarea name=\"" + name+"\" ";
59             if (cols != null) html += "cols=\"" + cols+"\" ";
60             if (rows != null) html += " rows=\"" + rows+"\" ";
61             html += ">";
62             if (values != null) {
63                 if (values.charAt(0) == '\"') {
64                     html += values.substring(1,values.length()-1);
65                 } else {
66                     html += values;
67                 }
68             }
69             html += "</textarea>";
70         }
71         return html;
72     }
73 }
74
Popular Tags