Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Wordsmithing opening paragraphs

Form input and validation is the most effective way for Forms are the traditional way for most web applications to gather significant information from the user. Whether it's a search form, a login screen or a multi-page registration wizard, forms are how the user really expresses themselves to the applicationTapestry uses standard HTML forms, with HTTP POST actions by default. In addition, AJAX-based form submission is supported using Zones.

Div
stylefloat:right
titleRelated Articles
classaui-label
Content by Label
showLabelsfalse
showSpacefalse
titleRelated Articles
cqllabel in ("validation","forms") and space = currentSpace()

 

Tapestry provides support for creating and rendering forms, populating their fields, and validating user input. For simple cases, input Tapestry excels at creating forms and validating input. Input validation is declarative, meaning you simply tell Tapestry what validations to apply to a given field, and it takes care of it on the server and (once implementedoptionally) on the client as well. In addition, you can provide event handler methods in your page or component classes to handle more complex validation scenarios.

Finally, Tapestry is able to not only makes it easy to present the errors back messages to the user, but to decorate the fields and the labels for the fields, marking them as containing errors (primarily, using CSS effects)it can also automatically highlight form fields when validation fails.

Contents

Table of Contents

...

The Form component emits a number of component events. You'll need want to provide event handler methods for some of these.

When rendering, the Form component emits two notifications: first, "prepareForRender", then "prepare". These allow the Form's container to setup set up any fields or properties that will be referenced in the form. For example, this is a good place to create a temporary entity object to be rendered, or to load an entity from a database to be edited.

...

Next, all the fields inside the form are activated to pull values out of the incoming request, validate them and (if valid) store the changes.

Wiki Markup
{float:right|width=25%|background=#eee}
_For Tapestry 4 Users:_ Tapestry 5 does not use the fragile "form rewind" approach from Tapestry 4. Instead, a hidden field generated during the render stores the information needed to process the form submission.
{float}
After the fields have done their processing, the Form emits a "validate" event. This is a your chance to perform any cross-form validation that can't be described declaratively.

...

In your own logic, it is possible to record your own errors. Form includes two different versions of method recordError(), one of which specifies a Field (an interface implemented by all form element components), and one of which is for "global" errors, unassociated not associated with any particular field. If the error concerns only a single field, you should use the first version so that the field will be highlighted.

Storing Data Between Requests

...