KickJava   Java API By Example, From Geeks To Geeks.

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


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: INPUT TEXT.
16  * Uses these 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 size : if not null the HTML tag SIZE=size is added </li>
22  * </ul>
23  *
24  * @application SCAN
25  * @author Jan van Oosterom
26  * @version $Id: HTMLElementText.java,v 1.6 2004/09/29 14:29:24 pierre Exp $
27  */

28 public class HTMLElementText extends HTMLElement {
29     /**
30      * Creates a HTMLElementText
31      */

32     public HTMLElementText() {
33     }
34
35     /**
36      * Generates the HTML code.
37      */

38     protected String JavaDoc generate() {
39         String JavaDoc html = "";
40         if (moreValues) {
41             Enumeration e = valuesList.elements();
42             if (e.hasMoreElements()) {
43                 String JavaDoc val = (String JavaDoc) e.nextElement();
44                 if (val.equals("null")) {
45                     val = "";
46                 }
47                 html += " <input type=\"text\" name=\"" + name + "\" ";
48                 html += "value=\"" + val + "\"";
49                 if (size != null) html += "size=\"" + size+"\"";
50                 html += ">" ;
51             }
52         } else {
53             if (values.equals("null")) {
54                 values = "";
55             }
56             html += " <input type=\"text\" name=\"" + name + "\" ";
57             if (values != null) html += "value=\"" + values + "\"";
58             if (size != null) html += "size=\"" + size+"\"";
59             html += ">";
60         }
61         return html;
62     }
63 }
64
Popular Tags