Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

So, this is a basic (very basic!) form and you can leave the fields blank and submit the form. With very little effort we can add client-side validation, to prevent the user from submitting the form with either field left blank.

Validation in Tapestry involves associating one or more validators with a form element component, such as TextField or PasswordField. This can be done using the validate parameter of the component itself.

...

The annotation may be placed on the getter or setter method, or on the field itself.

Update the two fields of the Login page:

Code Block
  @Persist
  @Property
  @Validate("required")
  private String userName;

  @Property
  @Validate("required")
 private String password;

Now, rebuild the app, refresh the browser, and just hit enter:

 

Customizing Validation Messages

...