com.ibm.as400.util.html.ButtonFormInput Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jt400 Show documentation
Show all versions of jt400 Show documentation
The Open Source version of the IBM Toolbox for Java
///////////////////////////////////////////////////////////////////////////////
//
// JTOpen (IBM Toolbox for Java - OSS version)
//
// Filename: ButtonFormInput.java
//
// The source code contained herein is licensed under the IBM Public License
// Version 1.0, which has been approved by the Open Source Initiative.
// Copyright (C) 1997-2000 International Business Machines Corporation and
// others. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
package com.ibm.as400.util.html;
import com.ibm.as400.access.Trace;
import com.ibm.as400.access.ExtendedIllegalStateException;
import com.ibm.as400.access.ExtendedIllegalArgumentException;
import java.beans.PropertyVetoException;
/**
* The ButtonFormInput class represents a button input type in an HTML form.
* The trailing slash "/" on the ButtonFormInput tag allows it to conform to
* the XHTML specification.
*
*
* Here is an example of a ButtonFormInput tag calling a javascript defined within a HTML page:
* <input type="button" name="button1" value="Press Me" onclick="test()" />
*
*
* Here is a sample javascript which displays an alert box with the specified message:
*
* <head>
* <script language="javascript">
* function test()
* {
* alert("This is a sample script executed with a ButtonFormInput.")
* }
* </script>
* </head>
*
*
* ButtonFormInput objects generate the following events:
*
* - PropertyChangeEvent
*
- VetoableChangeEvent
*
*
**/
public class ButtonFormInput extends FormInput
{
private static final String copyright = "Copyright (C) 1997-2000 International Business Machines Corporation and others.";
private String action_; // The action the button will perform when pressed.
/**
* Constructs a default ButtonFormInput object.
**/
public ButtonFormInput()
{
super();
}
/**
* Constructs a ButtonFormInput object with the specified control name.
* @param name The control name of the input field.
**/
public ButtonFormInput(String name)
{
super(name);
}
/**
* Constructs a ButtonFormInput object with the specified control name and
* viewable text value of the button.
* @param name The control name of the input field.
* @param value The viewable text value of the button.
**/
public ButtonFormInput(String name, String value)
{
super(name, value);
}
/**
* Constructs a ButtonFormInput object with the specified control name,
* viewable text value of the button, and the action to perform
* when the button is pressed.
* @param name The control name of the input field.
* @param value The viewable text value of the button.
* @param action The script to execute.
**/
public ButtonFormInput(String name, String value, String action) //$A1A
{
super(name, value);
try
{
setAction(action);
}
catch (PropertyVetoException e)
{
}
}
/**
* Returns the action being performed by the button.
* @return The script being executed.
**/
public String getAction() //$A1A
{
return action_;
}
/**
* Returns a comment tag.
* This method should not be called. There is no XSL-FO support for this class.
* @return The comment tag.
**/
public String getFOTag() //@D1A
{
Trace.log(Trace.ERROR, "Attempting to getFOTag() for an object that doesn't support it.");
return "";
}
/**
* Returns the tag for the button form input type.
* @return The tag.
**/
public String getTag()
{
if (getName() == null)
{
Trace.log(Trace.ERROR, "Attempting to get tag before setting name.");
throw new ExtendedIllegalStateException(
"name", ExtendedIllegalStateException.PROPERTY_NOT_SET );
}
StringBuffer s = new StringBuffer("");
return s.toString();
}
/**
* Sets the action to perform when the button is clicked. Buttons have no default behavior.
* Each button may have client-side scripts associated with the element's event attributes.
* When an event occurs (the user presses the button), the associated script is triggered.
* @param action The script to execute.
*
* @exception PropertyVetoException If a change is vetoed.
**/
public void setAction(String action) //$A1A
throws PropertyVetoException
{
if (action == null)
throw new NullPointerException("action");
if (action.length() == 0)
throw new ExtendedIllegalArgumentException("action",
ExtendedIllegalArgumentException.PARAMETER_VALUE_NOT_VALID);
String old = action_;
if (vetos_ != null) vetos_.fireVetoableChange("action", old, action); //@CRS
action_ = action;
if (changes_ != null) changes_.firePropertyChange("action", old, action); //@CRS
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy