com.sas.servlet.beans.html
Class Form

java.lang.Object
  |
  +--com.sas.Component
        |
        +--com.sas.servlet.beans.BaseTransformation
              |
              +--com.sas.servlet.beans.html.Form

public class Form
extends BaseTransformation
implements FormInterface

Convenience Object for creating HTML forms. A form can also perform client-side validations (via JavaScript) such as:

  • Required fields
  • Numeric input
  • Valid dates
  • Maximum lengths
  • Minimum/Maximum values
  • See Also:
    Serialized Form

    Field Summary
    static String DEFAULT_ENCODE_TYPE
               
    static String DEFAULT_METHOD
               
    static String DEFAULT_VALIDATION_FUNCTION_NAME
               
    static String RB_KEY
               
     
    Constructor Summary
    Form()
              Construct a new Form object
    Form(String name)
              Construct a new Form object
     
    Method Summary
    protected  int findBeanIndex(TransformationInterface bean)
              Finds the validation index of the given bean
     String getAction()
              Gets the URL which is used to post forms
     String getEncodeType()
              Gets the mechanism used to encode the form's content.
     String getMethod()
              Gets the HTTP method to be used when sending the form contents to the server.
     String getOnSubmitFunctionName()
              Returns the name of the function to call when the form is submitted
     String getValidationFunctionName()
              Gets the name of the validation function.
    protected  boolean isValidationNecessary(int type)
              Determines if a given validation type is necessary
     void setAction(String action)
              Sets the URL which is used to post forms via email (i.e "mailto:some.one@sas.com") or a server-side form handler (such as a servlet or JSP page) via HTTP (i.e.
     void setEncodeType(String enctype)
              Sets the mechanism used to encode the form's content.
     void setMethod(String method)
              Sets the HTTP method to be used when sending the form contents to the server.
     void setOnSubmitFunctionName(String name)
              Sets the name of the function to call when the form is submitted.
     void setValidationFunctionName(String name)
              Sets the name of the validation function to create if there are input fields associated with the form (via the validate methods).
     void validate(TransformationInterface bean, int type)
              Register a transformation bean to be validated before the form is submitted.
     void validate(TransformationInterface bean, int type, Object arg)
              Register a transformation bean to be validated before the form is submitted.
     void write(PrintWriter out)
              Writes the transformed representation of the object
     void writeFooter(OutputStream out)
              Writes the form footer
     void writeFooter(PrintWriter out)
              Writes the form footer
     void writeFooter(Writer out)
              Writes the form footer
     void writeHeader(OutputStream out)
              Writes the form header
     void writeHeader(PrintWriter out)
              Writes the form header
     void writeHeader(Writer out)
              Writes the form header
    protected  boolean writeValidations(PrintWriter out)
              Writes the validation routines
     
    Methods inherited from class com.sas.servlet.beans.BaseTransformation
    getCustomAttributes, getDescription, getName, getParent, getRequest, getResponse, setCustomAttributes, setDescription, setName, setParent, setRequest, setResponse, toString, write, write, write
     
    Methods inherited from class com.sas.Component
    addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, beansIsDesignTime, beansSetDesignTime, clone, clone, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getExtendedBeanInfo, getLinkInfo, getModelInterface, getRequiredInterfaces, getResources, getStringResource, getViewInterfaceSupportInfo, initialize, initializeComponent, isDesignTime, isLinked, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setDefaultValues, setLinkInfo, setModelInterface, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject
     
    Methods inherited from class java.lang.Object
    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    DEFAULT_METHOD

    public static final String DEFAULT_METHOD

    DEFAULT_ENCODE_TYPE

    public static final String DEFAULT_ENCODE_TYPE

    DEFAULT_VALIDATION_FUNCTION_NAME

    public static final String DEFAULT_VALIDATION_FUNCTION_NAME

    RB_KEY

    public static final String RB_KEY
    Constructor Detail

    Form

    public Form()
    Construct a new Form object

    Form

    public Form(String name)
    Construct a new Form object
    Parameters:
    name - The name of the form
    Method Detail

    setMethod

    public void setMethod(String method)
    Sets the HTTP method to be used when sending the form contents to the server. Valid values are "GET" and "POST". The default value is "GET"
    Specified by:
    setMethod in interface FormInterface
    Parameters:
    method - The HTTP method

    getMethod

    public String getMethod()
    Gets the HTTP method to be used when sending the form contents to the server.
    Specified by:
    getMethod in interface FormInterface
    Returns:
    The HTTP method

    setAction

    public void setAction(String action)
    Sets the URL which is used to post forms via email (i.e "mailto:some.one@sas.com") or a server-side form handler (such as a servlet or JSP page) via HTTP (i.e. "http://www.sas.com/jsp/my.jsp").
    Specified by:
    setAction in interface FormInterface
    Parameters:
    action - The action URL

    getAction

    public String getAction()
    Gets the URL which is used to post forms
    Specified by:
    getAction in interface FormInterface
    Returns:
    The action URL

    setEncodeType

    public void setEncodeType(String enctype)
    Sets the mechanism used to encode the form's content. The default is "application/x-www-form-urlencoded"
    Specified by:
    setEncodeType in interface FormInterface
    Parameters:
    enctype - The encode type

    getEncodeType

    public String getEncodeType()
    Gets the mechanism used to encode the form's content.
    Specified by:
    getEncodeType in interface FormInterface
    Returns:
    The encode type

    setValidationFunctionName

    public void setValidationFunctionName(String name)
    Sets the name of the validation function to create if there are input fields associated with the form (via the validate methods). The default is OnSubmit.
    Specified by:
    setValidationFunctionName in interface FormInterface
    Parameters:
    name - The validation function name

    getValidationFunctionName

    public String getValidationFunctionName()
    Gets the name of the validation function.
    Specified by:
    getValidationFunctionName in interface FormInterface
    Returns:
    The validation function name

    setOnSubmitFunctionName

    public void setOnSubmitFunctionName(String name)
    Sets the name of the function to call when the form is submitted. The default is OnSubmit. If the user wants to add additional validation code for the form the OnSubmitFunctionName can be set to a custom validation routine. The custom validation routine can invoke the standard validation function generated by this bean and, in turn, perform additional validation.
    Specified by:
    setOnSubmitFunctionName in interface FormInterface
    Parameters:
    name - The onSubmit function name

    getOnSubmitFunctionName

    public String getOnSubmitFunctionName()
    Returns the name of the function to call when the form is submitted
    Specified by:
    getOnSubmitFunctionName in interface FormInterface
    Returns:
    The onSubmit function name

    validate

    public void validate(TransformationInterface bean,
                         int type)

    Register a transformation bean to be validated before the form is submitted. A JavaScript function will be generated to perform the validation.

    For example, a Text Transformation Bean can be validated to be non-blank:

    validate(textBean, FormInterface.VALIDATE_REQUIRED);

    or numeric-only:

    validate(textBean, FormInterface.VALIDATE_NUMERIC);

    or both:

    validate(textBean, FormInterface.VALIDATE_REQUIRED | FormInterface.VALIDATE_NUMERIC);
    Specified by:
    validate in interface FormInterface
    Parameters:
    transformationBean - The input field to validate
    type - The type of validation

    validate

    public void validate(TransformationInterface bean,
                         int type,
                         Object arg)

    Register a transformation bean to be validated before the form is submitted. This method takes an additional validation type specific argument

    For example, a Text Transformation Bean can be validated to have a maximum length:

    validate(textBean, FormInterface.VALIDATE_MAXLENGTH, new Double(20));

    validate the minimum numeric value:

    validate(textBean, FormInterface.VALIDATE_MINVALUE, new Double(0));

    validate the minimum numeric value:

    validate(textBean, FormInterface.VALIDATE_MAXVALUE, new Double(100));
    Specified by:
    validate in interface FormInterface
    Parameters:
    transformationBean - The input field to validate
    type - The type of validation
    arg - The validation type specific argument

    findBeanIndex

    protected int findBeanIndex(TransformationInterface bean)
    Finds the validation index of the given bean
    Parameters:
    bean - The transformation bean
    Returns:
    The 0-based index in the validation vector, or -1 for not found

    write

    public void write(PrintWriter out)
               throws IOException
    Writes the transformed representation of the object
    Parameters:
    out - The output stream
    Overrides:
    write in class BaseTransformation

    writeHeader

    public void writeHeader(PrintWriter out)
                     throws IOException
    Writes the form header
    Specified by:
    writeHeader in interface FormInterface
    Parameters:
    out - The output stream
    Throws:
    IOException - Thrown if some type of I/O error occurs

    writeValidations

    protected boolean writeValidations(PrintWriter out)
                                throws IOException
    Writes the validation routines
    Parameters:
    out - The output stream
    Returns:
    true if validation routines were written

    isValidationNecessary

    protected boolean isValidationNecessary(int type)
    Determines if a given validation type is necessary
    Parameters:
    type - The validation type
    Returns:
    true if the validation is necessary

    writeHeader

    public void writeHeader(Writer out)
                     throws IOException
    Writes the form header
    Specified by:
    writeHeader in interface FormInterface
    Parameters:
    out - The output stream
    Throws:
    IOException - Thrown if some type of I/O error occurs

    writeHeader

    public void writeHeader(OutputStream out)
                     throws IOException
    Writes the form header
    Specified by:
    writeHeader in interface FormInterface
    Parameters:
    out - The output stream
    Throws:
    IOException - Thrown if some type of I/O error occurs

    writeFooter

    public void writeFooter(PrintWriter out)
                     throws IOException
    Writes the form footer
    Specified by:
    writeFooter in interface FormInterface
    Parameters:
    out - The output stream
    Throws:
    IOException - Thrown if some type of I/O error occurs

    writeFooter

    public void writeFooter(Writer out)
                     throws IOException
    Writes the form footer
    Specified by:
    writeFooter in interface FormInterface
    Parameters:
    out - The output stream
    Throws:
    IOException - Thrown if some type of I/O error occurs

    writeFooter

    public void writeFooter(OutputStream out)
                     throws IOException
    Writes the form footer
    Specified by:
    writeFooter in interface FormInterface
    Parameters:
    out - The output stream
    Throws:
    IOException - Thrown if some type of I/O error occurs


    Version: 1.2.20000317.001 Formatted: 2000/07/06 15:57:33PM