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

Quick Search    Search Deep

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


1   /*
2    * File: FormSubmit.java
3    * Auth: Mark Bednarczyk
4    * Date: DATE
5    *   Id: $Id: FormSubmit.java,v 1.1.1.1 2002/01/23 23:52:48 voytechs Exp $
6    ********************************************
7    * $Log: FormSubmit.java,v $
8    * Revision 1.1.1.1  2002/01/23 23:52:48  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 FormSubmit button.
24   */
25  public class FormSubmit 
26    extends FormComponent 
27    implements ButtonListenerIf {
28  
29    /* Internal attributes */
30  
31    /**
32     * Creates a submit button.
33     */
34    public FormSubmit(String label) throws EventException {
35      super(HtmlEvent.EVENT_SUBMIT_MASK);
36  
37      tagProperties.put("VALUE", label);
38  
39      addListener(new ListenerRequest(this, null, this));
40    }
41  
42    /**
43     * Output text to the HtmlWriter.
44     * @param htmlOut Out writer for this text.
45     */
46    public void paint(HtmlWriter htmlOut) throws IOException {
47      htmlOut.submit(getElementName(), tagProperties.toString());
48    }
49  
50    /**
51     * Set the text of the object.
52     * @param text FormSubmit to set in this component.
53     */
54    public void setLabel(String label) {
55      tagProperties.put("VALUE", label);
56    }
57  
58    /**
59     * Get the text of this object.
60     * @return FormSubmit of this component.
61     */
62    public String getLabel() {
63      return(tagProperties.getProperty("VALUE"));
64    }
65  
66    /**
67     * Add a button listener. Dispatched when the button is pressed on the HTML form.
68     */
69    public void addButtonListener(ButtonListenerIf listener, Object data) 
70      throws EventException {
71      
72      super.addListener(new ListenerRequest(listener, data, this));
73    }
74  
75    /**
76     * We listen to our own events so that we can update our state to match that
77     * on the HTML form.
78     * @param event Event with the new state of the button.
79     */
80    public void processEvent(HtmlButtonEvent event, Object userData) {
81      if(getLabel().equals(event.getValue()) == false) {
82        setLabel(event.getValue());
83      }
84    }
85  
86    /**
87     * Test function for FormSubmit
88     * @param args command line arguments
89     */
90    public static void main(String [] args) {
91    }
92  
93  } /* END OF: FormSubmit */