Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: List new client side validators for @AssertTrue @AssertFalse


Since
since5.2
 
Wiki Markup
{float:right|background=#eee}
{contentbylabel:title=Related Articles|showLabels=false|showSpace=false|space=TAPESTRY|labels=validation}
{float}

Integrate JSR 303 - Bean Validation API

Bean validation involves validating user input using Tapestry's built-in support for the JSR 303 Bean Validation API.

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

Tapestry has always provided a powerful non-JSR 303 Tapestry provides a powerful validation mechanism (see Forms and Validation). Among other things this mechanism allows you to annotate your domain model classes with the @Validate annotation. This However, this annotation is problematic if your domain model is used in non-Tapestry applications as well as in Tapestry applications. Your non-Tapestry application becomes dependent on tapestry5-annotations module. To make your domain model independent from Tapestry you can use the JSR 303: Bean Validation instead. This library provides integration between Tapestry and JSR-303.

...

Validating Beans with BeanEditForm

If you use the BeanEditForm component it's even easier to validate your beans. The only thing you have to do is to annotate your beans with JSR-303 annotations. If you are migrating from Tapestry's built-in validation mechanism to JSR-303 Bean Validation, you don't have to change your template at all.

...

JSR-303 constraint

Tapestry' JavaScript function

@Max

Tapestry.Validator.maxnumber

@Min

Tapestry.Validator.minnumber

@NotNull

Tapestry.Validator.notnull

@Null

Tapestry.Validator.isnull

@Pattern

Tapestry.Validator.pattern

@Size

Tapestry.Validator.size

@AssertTrue (Since 5.4.5)
@AssertFalse (Since 5.4.5)

Providing own client-side validators

Now let's see how to provide own client-side validation for JSR-303 constraints. Imagine you created the following constraint definition. The server-side implementation of the constraint is implemented by RangeValidator. I suppose you are familiar with JSR-303, so I don’t we won't explain how to implement RangeValidator.

...