Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/voytechs/html/component/FormTextField.java


1   /*
2    * File: FormTextField.java
3    * Auth: Mark Bednarczyk
4    * Date: DATE
5    *   Id: $Id: FormTextField.java,v 1.1.1.1 2002/01/23 23:52:47 voytechs Exp $
6    ********************************************
7    * $Log: FormTextField.java,v $
8    * Revision 1.1.1.1  2002/01/23 23:52:47  voytechs
9    * Initial public release, BETA 1.0 - voytechs
10   *
11   */
12  package com.voytechs.html.component;
13  
14  import com.voytechs.html.io.*;
15  import com.voytechs.html.event.*;
16  import com.voytechs.html.event.*;
17  
18  import java.lang.*;
19  
20  import java.io.IOException;
21  
22  /**
23   * A FormTextField button.
24   */
25  public class FormTextField 
26    extends FormComponent 
27    implements TextListenerIf {
28  
29    /* Internal attributes */
30  
31    /**
32     * Creates a submit button.
33     * @param
34     * @exception
35     */
36    public FormTextField(String defaultValue) throws EventException {
37      super(HtmlEvent.EVENT_TEXTFIELD_MASK);
38  
39      tagProperties.put("VALUE", defaultValue);
40  
41      addListener(new ListenerRequest(this, null, this));
42    }
43  
44    /**
45     * Output text to the HtmlWriter.
46     * @param htmlOut Out writer for this text.
47     */
48    public void paint(HtmlWriter htmlOut) throws IOException {
49      htmlOut.text(getElementName(), tagProperties.toString());
50    }
51  
52    /**
53     * Set the text of the object.
54     * @param text FormTextField to set in this component.
55     */
56    public void setValue(String value) {
57      tagProperties.put("VALUE", value);
58    }
59  
60    /**
61     * Get the text of this object.
62     * @return FormTextField of this component.
63     */
64    public String getValue() {
65      return(tagProperties.getProperty("VALUE"));
66    }
67  
68    /**
69     * Add a text change listener. Dispatched when the button is pressed on the HTML form and the text
70     * field's value changed.
71     */
72    public void addTextListener(TextListenerIf listener, Object data) 
73      throws EventException {
74      
75      super.addListener(new ListenerRequest(listener, data, this));
76    }
77  
78    /**
79     * We listen to our own events so that we can update our state to match that
80     * on the HTML form.
81     * @param event Event with the new state of the button.
82     */
83    public void processEvent(HtmlTextEvent event, Object userData) {
84      if(getValue().equals(event.getValue()) == false) {
85        setValue(event.getValue());
86      }
87    }
88  
89  
90    /**
91     * Test function for FormTextField
92     * @param args command line arguments
93     */
94    public static void main(String [] args) {
95    }
96  
97  } /* END OF: FormTextField */