org.apache.tapestry5.corelib.components
Class Form

java.lang.Object
  extended by org.apache.tapestry5.corelib.components.Form
All Implemented Interfaces:
ClientElement, FormValidationControl

@Events(value={"prepareForRender","prepare","prepareForSubmit","validateForm","submit","failure","success"})
public class Form
extends Object
implements ClientElement, FormValidationControl

An HTML form, which will enclose other components to render out the various types of fields.

A Form emits many notification events. When it renders, it fires a EventConstants.PREPARE_FOR_RENDER notification, followed by a EventConstants.PREPARE notification.

When the form is submitted, the component emits several notifications: first a EventConstants.PREPARE_FOR_SUBMIT, then a EventConstants.PREPARE: these allow the page to update its state as necessary to prepare for the form submission, then (after components enclosed by the form have operated), a EventConstants.VALIDATE_FORM event is emitted, to allow for cross-form validation. After that, either a EventConstants.SUCCESS OR EventConstants.FAILURE event (depending on whether the ValidationTracker has recorded any errors). Lastly, a EventConstants.SUBMIT event, for any listeners that care only about form submission, regardless of success or failure.

For all of these notifications, the event context is derived from the context parameter. This context is encoded into the form's action URI (the parameter is not read when the form is submitted, instead the values encoded into the form are used).


Field Summary
static String FAILURE
          Deprecated. Use constant from EventConstants instead.
static String FORM_DATA
          Query parameter name storing form data (the serialized commands needed to process a form submission).
static String PREPARE
          Deprecated. Use constant from EventConstants instead.
static String PREPARE_FOR_RENDER
          Deprecated. Use constant from EventConstants instead.
static String PREPARE_FOR_SUBMIT
          Deprecated. Use constant from EventConstants instead.
static String SUBMIT
          Deprecated. Use constant from EventConstants instead.
static String SUCCESS
          Deprecated. Use constant from EventConstants instead.
static String VALIDATE_FORM
          Deprecated. Use constant from EventConstants instead.
 
Constructor Summary
Form()
           
 
Method Summary
 void clearErrors()
          Invokes ValidationTracker.clear().
 String getClientId()
          Forms use the same value for their name and their id attribute.
 ValidationTracker getDefaultTracker()
           
 boolean getHasErrors()
          Returns true if the form's ValidationTracker contains any errors.
 boolean isValid()
          Returns true if the form's ValidationTracker does not contain any errors.
 void recordError(Field field, String errorMessage)
          A convienience for invoking ValidationTracker.recordError(Field, String).
 void recordError(String errorMessage)
          A convienience for invoking ValidationTracker.recordError(String).
 void setDefaultTracker(ValidationTracker defaultTracker)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREPARE_FOR_RENDER

public static final String PREPARE_FOR_RENDER
Deprecated. Use constant from EventConstants instead.
See Also:
Constant Field Values

PREPARE_FOR_SUBMIT

public static final String PREPARE_FOR_SUBMIT
Deprecated. Use constant from EventConstants instead.
See Also:
Constant Field Values

PREPARE

public static final String PREPARE
Deprecated. Use constant from EventConstants instead.
See Also:
Constant Field Values

SUBMIT

public static final String SUBMIT
Deprecated. Use constant from EventConstants instead.
See Also:
Constant Field Values

VALIDATE_FORM

public static final String VALIDATE_FORM
Deprecated. Use constant from EventConstants instead.
See Also:
Constant Field Values

SUCCESS

public static final String SUCCESS
Deprecated. Use constant from EventConstants instead.
See Also:
Constant Field Values

FAILURE

public static final String FAILURE
Deprecated. Use constant from EventConstants instead.
See Also:
Constant Field Values

FORM_DATA

public static final String FORM_DATA
Query parameter name storing form data (the serialized commands needed to process a form submission).

See Also:
Constant Field Values
Constructor Detail

Form

public Form()
Method Detail

getDefaultTracker

public ValidationTracker getDefaultTracker()

setDefaultTracker

public void setDefaultTracker(ValidationTracker defaultTracker)

recordError

public void recordError(String errorMessage)
Description copied from interface: FormValidationControl
A convienience for invoking ValidationTracker.recordError(String).

Specified by:
recordError in interface FormValidationControl

recordError

public void recordError(Field field,
                        String errorMessage)
Description copied from interface: FormValidationControl
A convienience for invoking ValidationTracker.recordError(Field, String).

Specified by:
recordError in interface FormValidationControl

getHasErrors

public boolean getHasErrors()
Description copied from interface: FormValidationControl
Returns true if the form's ValidationTracker contains any errors.

Specified by:
getHasErrors in interface FormValidationControl

isValid

public boolean isValid()
Description copied from interface: FormValidationControl
Returns true if the form's ValidationTracker does not contain any errors.

Specified by:
isValid in interface FormValidationControl

clearErrors

public void clearErrors()
Description copied from interface: FormValidationControl
Invokes ValidationTracker.clear().

Specified by:
clearErrors in interface FormValidationControl

getClientId

public String getClientId()
Forms use the same value for their name and their id attribute.

Specified by:
getClientId in interface ClientElement


Copyright © 2006-2009 Apache Software Foundation. All Rights Reserved.