...
After you do that, stop the app and restart it, and click on the Create new address link again, and you'll see something like this:
Tapestry has done quite a bit of work here. It has created a form that includes a field for each property. Further, it has seen that the honorific property is an enumerated type, and presented that as a drop-down list.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<t:beaneditform object="address" reorder="honorific,firstName,lastName,street1,street2,city,state,zip,email,phone" /> |
Customizing labels
...
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.
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 relabelling:
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.
...
Restart the application, and refresh your browser, then hit the Create Address button.
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 had an error message added. 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.
This is what you'll see after typing "abc" and clicking the Create Address button.
...
Refresh the page and submit again:
This trick isn't limited to just the regexp validator, it works equally well with any validator.
...