Book Image

Tapestry 5: Building Web Applications

Book Image

Tapestry 5: Building Web Applications

Overview of this book

Table of Contents (17 chapters)
Tapestry 5
Credits
About the Author
About the Reviewers
Preface
Foreword
Where to Go Next

Cross-Form Validation


We do need to perform custom validation in a couple of places. First of all, at the Registration page we should check whether the two versions of password are identical, and if not, we should report a problem.

To begin with, we need to have a reference to the Form component to record any eventual error in the page class code, and it is very easy to get:

@Component
private Form registrationForm;

Here the name of the private class member is the same as the ID of the Form component, so we do not need to clarify exactly which form we mean here.

We can record an error in the form in two ways—specifying the component which is in error and without mentioning any components. In the first case, the specified component will be marked as an error. Let's say that if passwords do not match, we want to mark the password component as an error. For this, we need to have a reference to this component in the page code:

@Component(id="password")
private PasswordField passwordField;

Here...