com.sas.servlet.tbeans.form.html
Class Form

com.sas.servlet.tbeans.form.html.Form
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.lang.ObjectDataInterface, RenderableInterface, TransformationInterface, com.sas.util.WriteToPrintWriterInterface, java.io.Serializable

public class Form

Convenience Object for creating HTML forms.

An HTML form is a section of a document containing normal content, markup, special elements called controls (checkboxes, radio buttons, menus, etc.), and labels on those controls. Users generally "complete" a form by modifying its controls (entering text, selecting menu items, etc.), before submitting the form to an agent for processing (e.g., to a Web server, to a mail server, etc.)

Note that the toString() method on this class calls the write method, which may have undesirable side effects. See BaseTransformation.toString() for more information. Debuggers often use toString() to show the value of a variable, and this may cause unexpected behavior while debugging

See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_ENCODE_TYPE
          Sets the default mechanism used to encode the form's content.
static java.lang.String DEFAULT_METHOD
          Sets the default HTTP method to be used when sending the form contents to the server.
static java.lang.String DEFAULT_VALIDATION_FUNCTION_NAME
          Sets the default name of the validation function to create if there are input fields associated with the form (via the validate methods).
 
Constructor Summary
Form()
          Construct a new Form object
Form(java.lang.String name)
          Construct a new Form object
 
Method Summary
 void addComponent(TransformationInterface bean)
          Registers components to the Form's component list.
 java.lang.String getAction()
          Gets the URL which is used to post forms
 java.lang.String getClearErrorsFunctionName()
          Gets the name of the clear errors function.
 java.util.List getComponents()
          Gets the components registered to the Form.
 java.lang.String getEncodeType()
          Gets the mechanism used to encode the form's content.
 java.lang.String getMethod()
          Gets the HTTP method to be used when sending the form contents to the server.
 java.lang.String getName()
          Gets the name that will be used to identify the content when it is submitted to the server
 java.lang.String getOnBlur()
          Gets the onBlur value.
 java.lang.String getOnClick()
          Gets the onClick value.
 java.lang.String getOnFocus()
          Gets the onFocus value.
 java.lang.String getOnKeyDown()
          Gets the onKeyDown value.
 java.lang.String getOnKeyPress()
          Gets the onKeyPress value.
 java.lang.String getOnKeyUp()
          Gets the onKeyUp value.
 java.lang.String getOnLoad()
          Gets the onLoad value.
 java.lang.String getOnMouseDown()
          Gets the onMouseDown value.
 java.lang.String getOnMouseOut()
          Gets the onMouseOut value.
 java.lang.String getOnMouseOver()
          Gets the onMouseOver value.
 java.lang.String getOnMouseUp()
          Gets the onMouseUp value.
 java.lang.String getOnReset()
          Gets the onReset value.
 java.lang.String getOnSubmit()
          Returns the name of the function to call when the form is submitted
 java.lang.String getOnSubmitFunctionCall()
          Gets the onSubmitFunctionCall value.
 java.lang.String getOnUnload()
          Gets the onUnload value.
 java.lang.String getProcessErrorsFunctionName()
          Gets the name of the process errors function.
 java.lang.String getRenderErrorsFunctionName()
          Gets the name of the render errors function.
 java.lang.String getTarget()
          Returns the window name that displays the data returned by the invoked program.
 java.lang.String getValidationFunctionName()
          Gets the name of the validation function.
 boolean isAutoComplete()
          Returns true if auto complete is turned on the form element, false otherwise.
 boolean isValidationEnabled()
          Returns the validationEnabled attribute of the Form Tag.
protected  boolean isValidationNecessary()
          Returns true if the validation for the form is enabled
 void setAction(java.lang.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 setAutoComplete(boolean value)
          Sets the state of the autoComplete on this form element.
 void setClearErrorsFunctionName(java.lang.String name)
          Sets the name of the clear errors function to call when validation fails.
 void setEncodeType(java.lang.String enctype)
          Sets the mechanism used to encode the form's content.
 void setMethod(java.lang.String method)
          Sets the HTTP method to be used when sending the form contents to the server.
 void setName(java.lang.String value)
          Sets the name that will be used to identify the content when it is submitted to the server
 void setOnBlur(java.lang.String value)
          Sets the onBlur event for the form.
 void setOnClick(java.lang.String value)
          Sets the onClick event for the form.
 void setOnFocus(java.lang.String value)
          Sets the onFocus event for the form.
 void setOnKeyDown(java.lang.String value)
          Sets the onKeyDown event for the form.
 void setOnKeyPress(java.lang.String value)
          Sets the onKeyPress event for the form.
 void setOnKeyUp(java.lang.String value)
          Sets the onKeyUp event for the form.
 void setOnLoad(java.lang.String value)
          Sets the onLoad event value.
 void setOnMouseDown(java.lang.String value)
          Sets the onMouseDown event for the form.
 void setOnMouseOut(java.lang.String value)
          Sets the onMouseOut event for the form.
 void setOnMouseOver(java.lang.String value)
          Sets the onMouseOver event for the form.
 void setOnMouseUp(java.lang.String value)
          Sets the onMouseUp event for the form.
 void setOnReset(java.lang.String value)
          Sets the onReset event value.
 void setOnSubmit(java.lang.String name)
          Sets the name of the function to call when the form is submitted.
 void setOnSubmitFunctionCall(java.lang.String name)
          Sets the onSubmitFunctionCall value.
 void setOnUnload(java.lang.String value)
          Sets the onUnload event value.
 void setProcessErrorsFunctionName(java.lang.String name)
          Sets the name of the process errors function to call if validation fails.
 void setRenderErrorsFunctionName(java.lang.String name)
          Sets the name of the render errors function to call if validation fails.
 void setTarget(java.lang.String target)
          Sets the window name that displays the data returned by the invoked program.
 void setValidationEnabled(boolean validationEnabled)
          Sets the the validationEnabled attribute on the Form The default is false.
 void setValidationFunctionName(java.lang.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 write(java.io.PrintWriter out)
          Writes the transformed representation of the object
 void writeFooter(java.io.OutputStream out)
          Writes the form footer
 void writeFooter(java.io.PrintWriter out)
          Writes the form footer
 void writeFooter(java.io.Writer out)
          Writes the form footer
 void writeHeader(java.io.OutputStream out)
          Writes the form header
 void writeHeader(java.io.PrintWriter out)
          Writes the form header
 void writeHeader(java.io.Writer out)
          Writes the form header
protected  boolean writeValidations(java.io.PrintWriter out)
          Writes the validation routines
 
Methods inherited from class com.sas.servlet.tbeans.BaseTransformation
addPropertyChangeListener, addPropertyChangeListener, cleanUpResources, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getCustomAttributes, getDescription, getId, getInputTransform, getLocale, getObjectData, getObjectDataProperty, getOutputTransform, getRequest, getResponse, getTagEpilog, getTagProlog, hasListeners, isCleanUpResourcesOn, isVisible, removePropertyChangeListener, removePropertyChangeListener, setCleanUpResourcesOn, setCustomAttributes, setDescription, setId, setInputTransform, setLocale, setLocaleDependentProperties, setObjectData, setObjectDataProperty, setOutputTransform, setRequest, setResponse, setTagEpilog, setTagProlog, setVisible, toString, write, write, write
 

Field Detail

DEFAULT_METHOD

public static final java.lang.String DEFAULT_METHOD
Sets the default HTTP method to be used when sending the form contents to the server.

See Also:
Constant Field Values

DEFAULT_ENCODE_TYPE

public static final java.lang.String DEFAULT_ENCODE_TYPE
Sets the default mechanism used to encode the form's content.

See Also:
Constant Field Values

DEFAULT_VALIDATION_FUNCTION_NAME

public static final java.lang.String DEFAULT_VALIDATION_FUNCTION_NAME
Sets the default name of the validation function to create if there are input fields associated with the form (via the validate methods).

See Also:
Constant Field Values
Constructor Detail

Form

public Form()
Construct a new Form object


Form

public Form(java.lang.String name)
Construct a new Form object

Parameters:
name - The name of the form
Method Detail

setName

public void setName(java.lang.String value)
Sets the name that will be used to identify the content when it is submitted to the server

Specified by:
setName in interface TransformationInterface
Overrides:
setName in class BaseTransformation
Parameters:
value - The name
See Also:
BaseTransformation.setId(java.lang.String)

getName

public java.lang.String getName()
Gets the name that will be used to identify the content when it is submitted to the server

Specified by:
getName in interface TransformationInterface
Overrides:
getName in class BaseTransformation
Returns:
The name
See Also:
BaseTransformation.getId()

setMethod

public void setMethod(java.lang.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 "post"

Parameters:
method - The HTTP method

getMethod

public java.lang.String getMethod()
Gets the HTTP method to be used when sending the form contents to the server.

Returns:
The HTTP method

setAction

public void setAction(java.lang.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").

Parameters:
action - The action URL

getAction

public java.lang.String getAction()
Gets the URL which is used to post forms

Returns:
The action URL

setEncodeType

public void setEncodeType(java.lang.String enctype)
Sets the mechanism used to encode the form's content. The default is "application/x-www-form-urlencoded"

Parameters:
enctype - The encode type

getEncodeType

public java.lang.String getEncodeType()
Gets the mechanism used to encode the form's content.

Returns:
The encode type

setValidationFunctionName

public void setValidationFunctionName(java.lang.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.

Parameters:
name - The validation function name

getValidationFunctionName

public java.lang.String getValidationFunctionName()
Gets the name of the validation function.

Returns:
The validation function name

setOnSubmit

public void setOnSubmit(java.lang.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 OnSubmit 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.

Parameters:
name - The onSubmit function name

getOnSubmit

public java.lang.String getOnSubmit()
Returns the name of the function to call when the form is submitted

Returns:
The onSubmit function name

setTarget

public void setTarget(java.lang.String target)
Sets the window name that displays the data returned by the invoked program.

Parameters:
target - The window name that displays the data returned by the invoked program.

getTarget

public java.lang.String getTarget()
Returns the window name that displays the data returned by the invoked program.

Returns:
The window name that displays the data returned by the invoked program.

setValidationEnabled

public void setValidationEnabled(boolean validationEnabled)
Sets the the validationEnabled attribute on the Form The default is false.

Parameters:
validationEnabled - The validationEnabled property

isValidationEnabled

public boolean isValidationEnabled()
Returns the validationEnabled attribute of the Form Tag.

Returns:
true if validationEnabled is selected

setOnBlur

public void setOnBlur(java.lang.String value)
Sets the onBlur event for the form. The onBlur event handler executes the specified JavaScript code or function on the occurance of a blur event. This is when a form loses focus. This can be caused by the user clicking outside of the form, or a call to the blur method on the form element.

Parameters:
value - The onBlur value

getOnBlur

public java.lang.String getOnBlur()
Gets the onBlur value.

Returns:
The onBlur event

setOnClick

public void setOnClick(java.lang.String value)
Sets the onClick event for the form. The onClick event handler executes the specified JavaScript code or function on the occurance of a click event.

Parameters:
value - The onClick value

getOnClick

public java.lang.String getOnClick()
Gets the onClick value.

Returns:
The onClick event

setOnFocus

public void setOnFocus(java.lang.String value)
Sets the onFocus event for the form. The onFocus event handler executes the specified JavaScript code or function on the occurance of a focus event. This is when a form is given focus. This can be caused by the user clicking on the form, by using the TAB key to cycle through the various elements on screen, or by a call to the focus method on the form.

Parameters:
value - The onFocus value

getOnFocus

public java.lang.String getOnFocus()
Gets the onFocus value.

Returns:
The onFocus event

setOnLoad

public void setOnLoad(java.lang.String value)
Sets the onLoad event value. The onload event handler executes the specified JavaScript code or function on the occurance of a Load event. A Load event occurs when the browser finishes loading a window or all the frames in a window.

Parameters:
value - The onLoad value

getOnLoad

public java.lang.String getOnLoad()
Gets the onLoad value.

Returns:
The onLoad event

setOnKeyDown

public void setOnKeyDown(java.lang.String value)
Sets the onKeyDown event for the form. The onKeyDown event handler executes the specified JavaScript code or function on the occurance of a KeyDown event. A KeyDown event occurs when the user depresses a key.

Parameters:
value - The onKeyDown value

getOnKeyDown

public java.lang.String getOnKeyDown()
Gets the onKeyDown value.

Returns:
The onKeyDown event

setOnKeyPress

public void setOnKeyPress(java.lang.String value)
Sets the onKeyPress event for the form. The onKeyPress event handler executes the specified JavaScript code or function on the occurance of a KeyPress event. A KeyPress event occurs when the user presses or holds down a key.

Parameters:
value - The onKeyPress value

getOnKeyPress

public java.lang.String getOnKeyPress()
Gets the onKeyPress value.

Returns:
The onKeyPress event

setOnKeyUp

public void setOnKeyUp(java.lang.String value)
Sets the onKeyUp event for the form. The onKeyUp event handler executes the specified JavaScript code or function on the occurance of a KeyUp event. A KeyUp event occurs when the user releases a key from its depressed position.

Parameters:
value - The onKeyUp value

getOnKeyUp

public java.lang.String getOnKeyUp()
Gets the onKeyUp value.

Returns:
The onKeyUp event

setOnMouseDown

public void setOnMouseDown(java.lang.String value)
Sets the onMouseDown event for the form. The onMouseDown event handler is used to execute specified Javascript code whenever the user depresses a mouse button.

Parameters:
value - The onMouseDown value

getOnMouseDown

public java.lang.String getOnMouseDown()
Gets the onMouseDown value.

Returns:
The onMouseDown event

setOnMouseUp

public void setOnMouseUp(java.lang.String value)
Sets the onMouseUp event for the form. The onMouseUp event handler is used to execute specified JavaScript code whenever the user releases the mouse button.

Parameters:
value - The onMouseUp value

getOnMouseUp

public java.lang.String getOnMouseUp()
Gets the onMouseUp value.

Returns:
The onMouseUp event

setOnMouseOut

public void setOnMouseOut(java.lang.String value)
Sets the onMouseOut event for the form. The onMouseOut event handler is used to execute specified Javascript code whenever the user moves the mouse out of a form from inside that form.

Parameters:
value - The onMouseOut value

getOnMouseOut

public java.lang.String getOnMouseOut()
Gets the onMouseOut value.

Returns:
The onMouseOut event

setOnMouseOver

public void setOnMouseOver(java.lang.String value)
Sets the onMouseOver event for the form. The onMouseOver event handler is used to execute specified Javascript code whenever the user moves the mouse over a form from outside that form.

Parameters:
value - The onMouseOver value

getOnMouseOver

public java.lang.String getOnMouseOver()
Gets the onMouseOver value.

Returns:
The onMouseOver event

setOnReset

public void setOnReset(java.lang.String value)
Sets the onReset event value. The onReset event handler is used to execute specified JavaScript code whenever the user resets a form by cicking a Reset button.

Parameters:
value - The onReset value

getOnReset

public java.lang.String getOnReset()
Gets the onReset value.

Returns:
The onReset event

setOnUnload

public void setOnUnload(java.lang.String value)
Sets the onUnload event value. The onUnload event handler is used to run a function or JavaScript code whenever the user exits a document.

Parameters:
value - The onUnload value

getOnUnload

public java.lang.String getOnUnload()
Gets the onUnload value.

Returns:
The onUnload event

addComponent

public void addComponent(TransformationInterface bean)
Registers components to the Form's component list. The component list is a list of components located inside the form. This list is used by the form when writing out validations that have been set on a component located inside the form. If the component has validators set on it but it has not been added to the form's component list, validation will not be performed for that component.

Parameters:
bean - The Form's registered components

getComponents

public java.util.List getComponents()
Gets the components registered to the Form.

Returns:
The Form's registered components

setOnSubmitFunctionCall

public void setOnSubmitFunctionCall(java.lang.String name)
Sets the onSubmitFunctionCall value. This is the javascript function that will be called when the form is submitted. * The function should look similar to function onSubmitFunctionCall(theForm) { ...... } The parameter is the form being submitted.

Parameters:
name - The onSubmitFunctionCall

getOnSubmitFunctionCall

public java.lang.String getOnSubmitFunctionCall()
Gets the onSubmitFunctionCall value.

Returns:
The function that's called when the form submits

setProcessErrorsFunctionName

public void setProcessErrorsFunctionName(java.lang.String name)
Sets the name of the process errors function to call if validation fails. This is the javascript function that will be called when validation fails on a component. * The function should look similar to function processErrorsFunctionCall(theForm) { ...... } The parameter is the form being submitted.

Parameters:
name - The process errors function name

getProcessErrorsFunctionName

public java.lang.String getProcessErrorsFunctionName()
Gets the name of the process errors function.

Returns:
The process errors function name

setRenderErrorsFunctionName

public void setRenderErrorsFunctionName(java.lang.String name)
Sets the name of the render errors function to call if validation fails. This is the javascript function that will be called to render errors when validation fails on a component. * The function should look similar to function renderErrorsFunctionCall(theForm, errMsgArray) { ...... } The fist parameter is the form being submitted. The second parameter is the array containing the error messages.

Parameters:
name - The render errors function name

getRenderErrorsFunctionName

public java.lang.String getRenderErrorsFunctionName()
Gets the name of the render errors function.

Returns:
The render errors function name

setClearErrorsFunctionName

public void setClearErrorsFunctionName(java.lang.String name)
Sets the name of the clear errors function to call when validation fails. This is the javascript function that will be called to clear errors when validation fails on a component. * The function should look similar to function clearErrorsFunctionCall(theForm) { ...... } The fist parameter is the form being submitted.

Parameters:
name - The clear errors function name

getClearErrorsFunctionName

public java.lang.String getClearErrorsFunctionName()
Gets the name of the clear errors function.

Returns:
The clear errors function name

write

public void write(java.io.PrintWriter out)
           throws java.io.IOException
Writes the transformed representation of the object

Specified by:
write in interface TransformationInterface
Specified by:
write in interface com.sas.util.WriteToPrintWriterInterface
Overrides:
write in class BaseTransformation
Parameters:
out - The output stream
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

writeHeader

public void writeHeader(java.io.PrintWriter out)
                 throws java.io.IOException
Writes the form header

Parameters:
out - The output stream
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

isValidationNecessary

protected boolean isValidationNecessary()
Returns true if the validation for the form is enabled

Returns:
true if validation is enabled; false otherwise

writeValidations

protected boolean writeValidations(java.io.PrintWriter out)
                            throws java.io.IOException
Writes the validation routines

Parameters:
out - The output stream
Returns:
true if validation routines were written
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

writeHeader

public void writeHeader(java.io.Writer out)
                 throws java.io.IOException
Writes the form header

Parameters:
out - The output stream
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

writeHeader

public void writeHeader(java.io.OutputStream out)
                 throws java.io.IOException
Writes the form header

Parameters:
out - The output stream
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

writeFooter

public void writeFooter(java.io.PrintWriter out)
                 throws java.io.IOException
Writes the form footer

Parameters:
out - The output stream
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

writeFooter

public void writeFooter(java.io.Writer out)
                 throws java.io.IOException
Writes the form footer

Parameters:
out - The output stream
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

writeFooter

public void writeFooter(java.io.OutputStream out)
                 throws java.io.IOException
Writes the form footer

Parameters:
out - The output stream
Throws:
java.io.IOException - Thrown if some type of I/O error occurs

setAutoComplete

public void setAutoComplete(boolean value)
Sets the state of the autoComplete on this form element. If autoComplete is turned off, the form element will write out autocomplete='off'; otherwise autocomplete property will not be written

Parameters:
value - the state of the form's auto completion

isAutoComplete

public boolean isAutoComplete()
Returns true if auto complete is turned on the form element, false otherwise.

Returns:
the state of the form's auto completion



Copyright © 2009 SAS Institute Inc. All Rights Reserved.