KickJava   Java API By Example, From Geeks To Geeks.

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


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 PASSWORD.
16  * Uses these variables which are set in the super class (HTMLElement) to generate HTML:
17  * <ul>
18  * <li>boolean moreValues : if true it will take the first value of a list of items.</li>
19  * <li>Vector valuesList : The list of items. </li>
20  * <li>String size : if not null the HTML tag SIZE=size is added </li>
21  * </ul>
22  *
23  * @application SCAN
24  * @author Jan van Oosterom
25  * @version $Id: HTMLElementPassword.java,v 1.6 2004/09/29 14:29:24 pierre Exp $
26  */

27 public class HTMLElementPassword extends HTMLElement {
28     // Note: more appropriate would be to extend from HTMLElementText
29

30     /**
31      * Creates a HTMLElementCheckbox
32      */

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

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