Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Resized images and other minor edits

...

Since this is a new file (and not a change to an existing file), you may have to restart Jetty to force Tapestry to pick up the change.

Create Address form with field labels corrected

We can also customize the options in the drop down list. All we have to do is add some more entries to the message catalog matching the enum names to the desired labels. Update CreateAddress.properties and add:

...

The final result shows the reformatting and relabelingrelabelling:


Create Address form with proper labels
Before continuing on to validation, a side note about message catalogs. Message catalogs are not just for re-labeling fields and options; we'll see in later chapters how message catalogs are used in the context of localization and internationalization.

...

No Format
submit-label=Create Address

At In the end of the day, the exact same HTML is sent to the client, regardless of whether you include the label text directly in the template, or indirectly in the message catalog. In the long term, the latter approach will work better if you later chose to internationalize your application.

...

Restart the application, and refresh your browser, then hit the Create Address button.

Form with client side validations visible

This is a shot just after hitting the Create Address button; all the fields have been validated and errors displayed. Each field in error has been highlighted in red and marked with a red "X". Further, the label for each of the fields has also been highlighted in red, to even more clearly identify what's in error. The cursor has also been moved to the first field that's in error. And all of this is taking place on the client side, without any communication with the application.

...

Let's give it a try; restart the application and enter an "abc" for the zip code.


Regexp validation
This is what you'll see after typing "abc" and tabbing out of the field, then tabbing back in. It's a little hard to capture all the animation effects in a still photoclicking the Create Address button.

In any case, that's the right validation behavior, but it's the wrong message. Your users are not going to know or care about regular expressions.

...

Refresh the page and submit again:

Regexp validation with corrected message

This trick isn't limited to just the regexp validator, it works equally well with any validator.

...