com.ibm.as400.util.html

Class HTMLForm

  • All Implemented Interfaces:
    HTMLConstants, HTMLTagElement, java.io.Serializable


    public class HTMLForm
    extends HTMLTagAttributes
    implements HTMLConstants, java.io.Serializable
    The HTMLForm class represents an HTML form.

    HTMLForm objects generate the following events:

    • ElementEvent - The events fired are:
      • elementAdded
      • elementRemoved
    • PropertyChangeEvent
    • VetoableChangeEvent

    This examples creates an HTMLForm object and adds some form input types to it.

      // Create a text input form element for the system.
      LabelFormElement sysPrompt = new LabelFormElement("System:");
      TextFormInput system = new TextFormInput("System");
      
      // Create a text input form element for the userId.
      LabelFormElement userPrompt = new LabelFormElement("User:");
      TextFormInput user = new TextFormInput("User");
    
      // Create a password input form element for the password.
      LabelFormElement passwordPrompt = new LabelFormElement("Password:");
      PasswordFormInput password = new PasswordFormInput("Password");
    
      // Create a properties object.
      Properties prop = new Properties();
     
      // Add customer name and ID values to the properties object.
      prop.put("custName", "Mr. Toolbox");
      prop.put("custID", "12345");
      
      // Create the submit button to the form.
      SubmitFormInput logonButton = new SubmitFormInput("logon", "Logon");
      
      // Create HTMLForm object and add the panel to it.
      HTMLForm form = new HTMLForm(servletURI);
      form.setHiddenParameterList(prop);
      form.addElement(sysPrompt);
      form.addElement(system);
      form.addElement(userPrompt);
      form.addElement(user);
      form.addElement(passwordPrompt);
      form.addElement(password);
      form.addElement(logonButton);
      

    Here is an example of an HTMLForm tag:

      <form action="servletURI" method="get">
         System:   <input type="text" name="System" />
         User:     <input type="text" name="User" />
         Password: <input type="password" name="Password" />
         <input type="submit" name="logon" value="Logon" />
         <input type="hidden" name="custName" value="Mr. Toolbox" />
         <input type="hidden" name="custID" value="12345" />
      </form>
      
    See Also:
    Serialized Form
    • Field Detail

      • METHOD_GET

        public static final int METHOD_GET
        HTTP GET Method for sending form contents to the server. This is the default method used.
        See Also:
        Constant Field Values
      • METHOD_POST

        public static final int METHOD_POST
        HTTP POST Method for sending form contents to the server.
        See Also:
        Constant Field Values
    • Constructor Detail

      • HTMLForm

        public HTMLForm()
        Constructs a default HTMLForm object.
      • HTMLForm

        public HTMLForm(java.lang.String url)
        Constructs an HTMLForm object with the specified URL.
        Parameters:
        url - The URL address.
    >
    • Method Detail

      • addElement

        public void addElement(HTMLTagElement element)
        Adds a form element to the HTMLForm.
        Parameters:
        element - The form element.
      • addVetoableChangeListener

        public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
        Adds the VetoableChangeListener. The specified VetoableChangeListener's vetoableChange method is called each time the value of any constrained property is changed.
        Parameters:
        listener - The VetoableChangeListener.
        See Also:
        removeVetoableChangeListener(java.beans.VetoableChangeListener)
      • getDirection

        public java.lang.String getDirection()
        Returns the direction of the text interpretation.
        Returns:
        The direction of the text.
      • getHiddenParameterList

        public java.util.Properties getHiddenParameterList()
        Returns the form's hidden parameter list.
        Returns:
        The parameter list.
      • getLanguage

        public java.lang.String getLanguage()
        Returns the language of the input element.
        Returns:
        The language of the input element.
      • getMethod

        public int getMethod()
        Returns the HTTP method used for sending form contents to the server.
        Returns:
        The HTTP method.
      • getFOTag

        public java.lang.String getFOTag()
        Returns a comment tag. This method should not be called. There is no XSL-FO support for this class.
        Specified by:
        getFOTag in interface HTMLTagElement
        Returns:
        The comment tag.
      • getTag

        public java.lang.String getTag()
        Returns the HTML form tag.
        Specified by:
        getTag in interface HTMLTagElement
        Returns:
        The tag.
      • getTarget

        public java.lang.String getTarget()
        Returns the target frame for the form response.
        Returns:
        The target frame. One of the following constants defined in HTMLConstants: TARGET_BLANK, TARGET_PARENT, TARGET_SELF, TARGET_TOP, or a user defined target.
        See Also:
        HTMLConstants
      • getURL

        public java.lang.String getURL()
        Returns the ACTION URL address of the server-side form handler.
        Returns:
        The URL address.
      • isUseGet

        public boolean isUseGet()
        Indicates if the GET method is used for sending the form contents to the server.
        Returns:
        true if GET is used; false otherwise.
      • isUsePost

        public boolean isUsePost()
        Indicates if the POST method is used for sending the form contents to the server.
        Returns:
        true if POST is used; false otherwise.
      • removeElement

        public void removeElement(HTMLTagElement element)
        Removes a form element from the HTMLForm.
        Parameters:
        element - The form element.
      • removeVetoableChangeListener

        public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
        Removes the VetoableChangeListener from the internal list. If the VetoableChangeListener is not on the list, nothing is done.
        Parameters:
        listener - The VetoableChangeListener.
        See Also:
        addVetoableChangeListener(java.beans.VetoableChangeListener)
      • setDirection

        public void setDirection(java.lang.String dir)
                          throws java.beans.PropertyVetoException
        Sets the direction of the text interpretation.
        Parameters:
        dir - The direction. One of the following constants defined in HTMLConstants: LTR or RTL.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
        See Also:
        HTMLConstants
      • setHiddenParameterList

        public void setHiddenParameterList(java.util.Properties parameterList)
                                    throws java.beans.PropertyVetoException
        Sets the form's hidden parameter list.
        Parameters:
        parameterList - The parameter list.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • setLanguage

        public void setLanguage(java.lang.String lang)
                         throws java.beans.PropertyVetoException
        Sets the language of the input tag.
        Parameters:
        lang - The language. Example language tags include: en and en-US.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • setMethod

        public void setMethod(int method)
                       throws java.beans.PropertyVetoException
        Sets the HTTP method used to send form contents to the server.
        Parameters:
        method - The method.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • setTarget

        public void setTarget(java.lang.String target)
                       throws java.beans.PropertyVetoException
        Sets the target frame for the form response.
        Parameters:
        target - The target frame. One of the following constants defined in HTMLConstants: TARGET_BLANK, TARGET_PARENT, TARGET_SELF, TARGET_TOP, or a user defined target.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
        See Also:
        HTMLConstants
      • setURL

        public void setURL(java.lang.String url)
                    throws java.beans.PropertyVetoException
        Sets the ACTION URL address of the server-side form handler.
        Parameters:
        url - The URL address.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • toString

        public java.lang.String toString()
        Returns the HTMLForm tag as a String.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The tag.