com.meterware.httpunit
Class Button

java.lang.Object
  |
  +--com.meterware.httpunit.HTMLElementBase
        |
        +--com.meterware.httpunit.FormControl
              |
              +--com.meterware.httpunit.Button
All Implemented Interfaces:
HTMLElement
Direct Known Subclasses:
ResetButton, SubmitButton

public class Button
extends com.meterware.httpunit.FormControl

A button in a form.

Author:
Russell Gold

Field Summary
static HTMLElementPredicate WITH_ID
           
static HTMLElementPredicate WITH_LABEL
           
 
Method Summary
protected  void claimValueIsRequired(java.util.List values, java.lang.String value)
          Removes the specified required value from the list of values, throwing an exception if it is missing.
 void click()
          Performs the action associated with clicking this button after running any 'onClick' script.
protected  void doButtonAction()
          Perform the normal action of this button.
protected  boolean doOnClickEvent()
          Does the 'onClick' event defined for this button.
protected  java.lang.String getAttribute(java.lang.String name)
           
protected  java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
           
 java.lang.String getClassName()
          Returns the class associated with this element.
protected  WebForm getForm()
           
 java.lang.String getID()
          Returns the ID associated with this element.
 java.lang.String getName()
          Returns the name associated with this element.
protected  org.w3c.dom.Node getNode()
           
 java.lang.String[] getOptionValues()
          Returns the values permitted in this control.
protected  com.meterware.httpunit.scripting.ScriptableDelegate getParentDelegate()
          Returns the scriptable delegate which can provide the scriptable delegate for this element.
 com.meterware.httpunit.scripting.ScriptableDelegate getScriptableDelegate()
          Returns a scriptable object which can act as a proxy for this control.
 java.lang.String getTitle()
          Returns the title associated with this element.
 java.lang.String getValue()
          Returns the value associated with this button.
protected  java.lang.String getValueAttribute()
          Returns the default value of this control in the form.
 boolean isDisabled()
          Returns true if this button is disabled, meaning that it cannot be clicked.
protected  com.meterware.httpunit.scripting.ScriptableDelegate newScriptable()
          Creates and returns a scriptable object for this control.
protected  void sendOnChangeEvent()
          Performs the 'onChange' event defined for this control.
protected  void sendOnClickEvent()
          Performs the 'onClick' event defined for this control.
 void setState(boolean state)
          Sets the state of this boolean control.
 void toggle()
          Toggles the value of this control.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WITH_ID

public static final HTMLElementPredicate WITH_ID

WITH_LABEL

public static final HTMLElementPredicate WITH_LABEL
Method Detail

getValue

public java.lang.String getValue()
Returns the value associated with this button.


click

public void click()
           throws java.io.IOException,
                  org.xml.sax.SAXException
Performs the action associated with clicking this button after running any 'onClick' script. For a submit button this typically submits the form.

java.io.IOException
org.xml.sax.SAXException

isDisabled

public boolean isDisabled()
Returns true if this button is disabled, meaning that it cannot be clicked.

Overrides:
isDisabled in class com.meterware.httpunit.FormControl

doOnClickEvent

protected final boolean doOnClickEvent()
Does the 'onClick' event defined for this button.

Returns:
true if subsequent actions should be performed.

doButtonAction

protected void doButtonAction()
                       throws java.io.IOException,
                              org.xml.sax.SAXException
Perform the normal action of this button.

java.io.IOException
org.xml.sax.SAXException

newScriptable

protected com.meterware.httpunit.scripting.ScriptableDelegate newScriptable()
Description copied from class: com.meterware.httpunit.FormControl
Creates and returns a scriptable object for this control. Subclasses should override this if they use a different implementation of Scriptable.

Overrides:
newScriptable in class com.meterware.httpunit.FormControl

getForm

protected final WebForm getForm()

getParentDelegate

protected com.meterware.httpunit.scripting.ScriptableDelegate getParentDelegate()
Description copied from class: com.meterware.httpunit.HTMLElementBase
Returns the scriptable delegate which can provide the scriptable delegate for this element.

Specified by:
getParentDelegate in class com.meterware.httpunit.HTMLElementBase

getOptionValues

public java.lang.String[] getOptionValues()
Returns the values permitted in this control. Does not apply to text or file controls.


toggle

public void toggle()
Toggles the value of this control.


setState

public void setState(boolean state)
Sets the state of this boolean control.


sendOnChangeEvent

protected void sendOnChangeEvent()
Performs the 'onChange' event defined for this control.


sendOnClickEvent

protected void sendOnClickEvent()
Performs the 'onClick' event defined for this control.


getValueAttribute

protected java.lang.String getValueAttribute()
Returns the default value of this control in the form. If no value is specified, defaults to the empty string.


claimValueIsRequired

protected final void claimValueIsRequired(java.util.List values,
                                          java.lang.String value)
Removes the specified required value from the list of values, throwing an exception if it is missing.


getID

public java.lang.String getID()
Description copied from interface: HTMLElement
Returns the ID associated with this element. IDs are unique throughout the HTML document.

Specified by:
getID in interface HTMLElement

getClassName

public java.lang.String getClassName()
Description copied from interface: HTMLElement
Returns the class associated with this element.

Specified by:
getClassName in interface HTMLElement

getTitle

public java.lang.String getTitle()
Description copied from interface: HTMLElement
Returns the title associated with this element.

Specified by:
getTitle in interface HTMLElement

getName

public java.lang.String getName()
Description copied from interface: HTMLElement
Returns the name associated with this element.

Specified by:
getName in interface HTMLElement

getScriptableDelegate

public com.meterware.httpunit.scripting.ScriptableDelegate getScriptableDelegate()
Returns a scriptable object which can act as a proxy for this control.

Specified by:
getScriptableDelegate in interface HTMLElement

getAttribute

protected java.lang.String getAttribute(java.lang.String name)

getAttribute

protected java.lang.String getAttribute(java.lang.String name,
                                        java.lang.String defaultValue)

getNode

protected org.w3c.dom.Node getNode()

Copyright © 2000-2003 Russell Gold. See license agreement for rights granted.