Author: buildbot
Date: Fri Jan 25 12:21:24 2019
New Revision: 1039509
Log:
Production update by buildbot for tapestry
Modified:
websites/production/tapestry/content/bean-validation.html
websites/production/tapestry/content/cache/main.pageCache
websites/production/tapestry/content/forms-and-validation.html
Modified: websites/production/tapestry/content/bean-validation.html
==============================================================================
--- websites/production/tapestry/content/bean-validation.html (original)
+++ websites/production/tapestry/content/bean-validation.html Fri Jan 25
12:21:24 2019
@@ -92,11 +92,13 @@
+
+
<h3>Related Articles</h3>
<ul class="content-by-label"><li>
<div>
- <span class="icon aui-icon aui-icon-small
aui-iconfont-page-default" title="Page">Page:</span> </div>
+ <span class="icon aui-icon content-type-page"
title="Page">Page:</span> </div>
<div class="details">
<a href="bean-validation.html">Bean Validation</a>
@@ -105,7 +107,7 @@
</div>
</li><li>
<div>
- <span class="icon aui-icon aui-icon-small
aui-iconfont-page-default" title="Page">Page:</span> </div>
+ <span class="icon aui-icon content-type-page"
title="Page">Page:</span> </div>
<div class="details">
<a href="forms-and-validation.html">Forms and
Validation</a>
@@ -117,7 +119,7 @@
<p>Tapestry has always provided a powerful non-JSR 303 validation mechanism
(see <a href="forms-and-validation.html">Forms and Validation</a>). Among
other things this mechanism allows you to annotate your domain model classes
with the <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beaneditor/Validate.html">@Validate</a>
annotation. 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 <em>tapestry5-annotations</em>
module. To make your domain model independent from Tapestry you can use the <a
class="external-link" href="http://jcp.org/en/jsr/detail?id=303"
rel="nofollow">JSR 303: Bean Validation</a> instead. This library provides
integration between Tapestry and JSR-303.</p><h2
id="BeanValidation-Configuration">Configuration</h2><p>The Tapestry's JSR 303 -
Bean Validation Library is responsible for con
figuring and bootstrapping the <a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/Validator.html"
rel="nofollow">Validator</a> for you. In order to use this library you have to
choose an implementation of the JSR-303 specification like <a
class="external-link" href="https://www.hibernate.org/412.html"
rel="nofollow">Hibernate Validator 4.x</a>. This library is not specific to any
implementation of JSR-303 and will work with any implementation of your
choice.</p><h3 id="BeanValidation-BootstrapingtheBeanValidator">Bootstraping
the Bean Validator</h3><p>The <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beanvalidator/BeanValidatorSource.html">BeanValidatorSource</a>
service is responsible for bootstrapping the <a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/Validator.html"
rel="nofollow">Validator</a>. You can contribute a <a class="external-link"
href="htt
p://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beanvalidator/BeanValidatorConfigurer.html">BeanValidatorConfigurer</a>
to the configuration of this service in order to participate on the
configuration of <a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/Validator.html"
rel="nofollow">Validator</a>.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">@Contribute(BeanValidatorSource.class)
+<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java;
gutter: false; theme: Default"
data-theme="Default">@Contribute(BeanValidatorSource.class)
public static void
provideBeanValidatorConfigurer(OrderedConfiguration<BeanValidatorConfigurer>
configuration)
{
configuration.add("MyConfigurer", new BeanValidatorConfigurer()
@@ -129,7 +131,7 @@ public static void provideBeanValidatorC
});
}</pre>
</div></div><h3 id="BeanValidation-Validationgroups">Validation
groups</h3><p>In JSR-303 validation groups are used to define a subset of the
constraints validated at a given time. If no validation group is specified the
<a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/groups/Default.html"
rel="nofollow">Default</a> group is taken. By default, Tapestry passes only
this group to <a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/Validator.html"
rel="nofollow">Validator</a>. You can tell Tapestry to pass more groups by
contributing group classes into the configuration of the <a
class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beanvalidator/BeanValidatorSource.html">BeanValidatorSource</a>
service.</p><h2 id="BeanValidation-Usage">Usage</h2><h3
id="BeanValidation-ValidatingInputFields">Validating Input Fields</h3><p>Once
you included this library and its dependencie
s into your web app, you may use the JSR-303 annotations to validate the
user's input.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public class Login
+<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java;
gutter: false; theme: Default" data-theme="Default">public class Login
{
@NotNull
@Size(max=10)
@@ -148,7 +150,7 @@ public static void provideBeanValidatorC
}
}</pre>
</div></div><p>You can even mix JSR-303 annotations and Tapestry's @<a
class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beaneditor/Validate.html">Validate</a>
annotation.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public class Login
+<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java;
gutter: false; theme: Default" data-theme="Default">public class Login
{
@NotNull
@Validate("maxlength=10")
@@ -167,7 +169,7 @@ public static void provideBeanValidatorC
}
}</pre>
</div></div><p>Next you have to pass the object to validate into the Form's
<em>validate</em> parameter. In the following example the Form's fields are
bound to the properties of the <em>Login</em> page. That's why we pass
<em>this</em>, thus the page instance, to the  <em>validate</em>
parameter.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"><html
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
+<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: xml;
gutter: false; theme: Default" data-theme="Default"><html
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
<body>
<t:form validate="this">
@@ -188,7 +190,7 @@ public static void provideBeanValidatorC
</body>
</html></pre>
</div></div><p>Since the <em>validate</em> parameter defaults to the container
of the Form component, we could also remove <em>validate="this"</em> in the
example above.</p><h3
id="BeanValidation-ValidatingBeanswithBeanEditForm">Validating Beans with
BeanEditForm</h3><p>If you use the <a
href="beaneditform-guide.html">BeanEditForm</a> 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.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public class User
+<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java;
gutter: false; theme: Default" data-theme="Default">public class User
{
@NotNull
private String userName;
@@ -199,8 +201,8 @@ public static void provideBeanValidatorC
...
}</pre>
-</div></div><h3 id="BeanValidation-Client-sideValidation">Client-side
Validation</h3><p>Unfortunately JSR-303 doesn’t cover client-side
validation, so web frameworks supporting this JSR need to come up with
proprietary client-side solutions. Tapestry provides client-side validation for
the following JSR-303 constraints:</p><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>JSR-303 constraint</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry' JavaScript function</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/Max.html"
rel="nofollow">@Max</a></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry.Validator.maxnumber</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax
/validation/constraints/Min.html" rel="nofollow">@Min</a></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry.Validator.minnumber</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/NotNull.html"
rel="nofollow">@NotNull</a></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry.Validator.notnull</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/Null.html"
rel="nofollow">@Null</a></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry.Validator.isnull</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/Pattern.html"
rel="nofollow">@Pattern</a></p></td><td colspan="1" rowspan="1" class="conf
luenceTd"><p>Tapestry.Validator.pattern</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/Size.html"
rel="nofollow">@Size</a></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry.Validator.size</p></td></tr></tbody></table></div><h3
id="BeanValidation-Providingownclient-sidevalidators">Providing own
client-side validators</h3><p>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 we
won't explain how to implement RangeValidator.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">@Documented
+</div></div><h3 id="BeanValidation-Client-sideValidation">Client-side
Validation</h3><p>Unfortunately JSR-303 doesn’t cover client-side
validation, so web frameworks supporting this JSR need to come up with
proprietary client-side solutions. Tapestry provides client-side validation for
the following JSR-303 constraints:</p><div class="table-wrap"><table
class="confluenceTable"><colgroup span="1"><col span="1"><col
span="1"></colgroup><tbody><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>JSR-303 constraint</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry' JavaScript function</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/Max.html"
rel="nofollow">@Max</a></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry.Validator.maxnumber</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><a class="external
-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/Min.html"
rel="nofollow">@Min</a></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry.Validator.minnumber</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/NotNull.html"
rel="nofollow">@NotNull</a></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry.Validator.notnull</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/Null.html"
rel="nofollow">@Null</a></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry.Validator.isnull</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/Pattern.html"
rel="nofollow">@P
attern</a></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry.Validator.pattern</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/Size.html"
rel="nofollow">@Size</a></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Tapestry.Validator.size</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/AssertTrue.html"
rel="nofollow">@AssertTrue</a> <em>(Since 5.4.5)</em></td><td colspan="1"
rowspan="1" class="confluenceTd"><br clear="none"></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><a class="external-link"
href="http://download.oracle.com/javaee/6/api/javax/validation/constraints/AssertFalse.html"
rel="nofollow">@AssertFalse</a> <em>(Since 5.4.5)</em></td><td colspan="1"
rowspan="1" class="confluenceTd"><br clear="
none"></td></tr></tbody></table></div><h3
id="BeanValidation-Providingownclient-sidevalidators">Providing own client-side
validators</h3><p>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 we won't explain
how to implement RangeValidator.</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java;
gutter: false; theme: Default" data-theme="Default">@Documented
@Constraint(validatedBy = RangeValidator.class)
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@@ -216,7 +218,7 @@ public @interface Range {
Class[] payload() default {};
}</pre>
</div></div><p>To provide client-side validation of a constraint you have to
add a JavaScript function to the built-in <em>Tapestry.Validator</em>
JavaScript-object. The function should contain exactly three
parameters:</p><ol><li>Field being validated</li><li>Validation
message</li><li>JSON object with values from the constraint
annotation</li></ol><p>Here is an example:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: js; gutter: false; theme: Default"
style="font-size:12px;">Tapestry.Validator.range = function(field, message,
spec) {
+<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: js;
gutter: false; theme: Default" data-theme="Default">Tapestry.Validator.range =
function(field, message, spec) {
field.addValidator(function(value) {
if (value < spec.min || value > spec.max) {
throw message;
@@ -224,7 +226,7 @@ public @interface Range {
});
};</pre>
</div></div><p>Now you have to tell Tapestry to call the function
<em>Tapestry.Validator.range</em> when client-side validation of
<em>@Range</em> should be executed. This is accomplished by a contribution to
the <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beanvalidator/ClientConstraintDescriptorSource.html">ClientConstraintDescriptorSource</a>
service. The configuration of this service is a collection of <a
class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beanvalidator/ClientConstraintDescriptor.html">ClientConstraintDescriptor</a>.
Each <em>ClientConstraintDescriptor</em> represents a client-side validation
constraint. The constructor of <em>ClientConstraintDescriptor</em> has three
parameters:</p><ol><li>Class of the constraint annotation.</li><li>Name of the
JavaScript function.</li><li>The last parameter is a varargs. It is used to
pass the attribute names of the constraint annotatio
n to be passed (along with their values) to the JavaScript function as an JSON
object.</li></ol><p>The last step is to make the contribution, which links the
<em>@Range</em> annotation with the JavaScript function <em>range</em>. The
attributes <em>max</em> and <em>min</em> and their values are passed to the
function.</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">@Contribute(ClientConstraintDescriptorSource.class)
+<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java;
gutter: false; theme: Default"
data-theme="Default">@Contribute(ClientConstraintDescriptorSource.class)
public static void
provideClientConstraintDescriptors(Configuration<ClientConstraintDescriptor>
config) {
config.add(new ClientConstraintDescriptor(Range.class, "range", "min",
"max"));
Modified: websites/production/tapestry/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/tapestry/content/forms-and-validation.html
==============================================================================
--- websites/production/tapestry/content/forms-and-validation.html (original)
+++ websites/production/tapestry/content/forms-and-validation.html Fri Jan 25
12:21:24 2019
@@ -104,7 +104,7 @@
<span class="icon aui-icon content-type-page"
title="Page">Page:</span> </div>
<div class="details">
- <a href="forms-and-form-components-faq.html">Forms
and Form Components FAQ</a>
+ <a href="bean-validation.html">Bean Validation</a>
</div>
@@ -113,7 +113,7 @@
<span class="icon aui-icon content-type-page"
title="Page">Page:</span> </div>
<div class="details">
- <a href="bean-validation.html">Bean Validation</a>
+ <a href="forms-and-form-components-faq.html">Forms
and Form Components FAQ</a>
</div>
@@ -122,11 +122,11 @@
<p> </p><p>Tapestry provides support for creating and rendering forms,
populating their fields, and validating user input. For simple cases, input
validation is declarative, meaning you simply tell Tapestry what validations to
apply to a given field, and it takes care of it on the server and (optionally)
on the client as well. In addition, you can provide event handler
methods in your page or component classes to handle more complex
validation scenarios.</p><p>Finally, Tapestry not only makes it easy to present
errors messages to the user, but it can also automatically highlight form
fields when validation fails.</p><p><strong>Contents</strong></p><p><style
type="text/css">/*<![CDATA[*/
-div.rbtoc1548415261309 {padding: 0px;}
-div.rbtoc1548415261309 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1548415261309 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1548418863351 {padding: 0px;}
+div.rbtoc1548418863351 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1548418863351 li {margin-left: 0px;padding-left: 0px;}
-/*]]>*/</style></p><div class="toc-macro rbtoc1548415261309">
+/*]]>*/</style></p><div class="toc-macro rbtoc1548418863351">
<ul class="toc-indentation"><li>Related Articles</li></ul>
<ul><li><a href="#FormsandValidation-TheFormComponent">The Form Component</a>
<ul class="toc-indentation"><li><a href="#FormsandValidation-FormEvents">Form
Events</a></li><li><a href="#FormsandValidation-HandlingEvents">Handling
Events</a></li><li><a
href="#FormsandValidation-TrackingValidationErrors">Tracking Validation
Errors</a></li><li><a
href="#FormsandValidation-StoringDataBetweenRequests">Storing Data Between
Requests</a></li><li><a
href="#FormsandValidation-ConfiguringFieldsandLabels">Configuring Fields and
Labels</a></li></ul>
@@ -135,7 +135,7 @@ div.rbtoc1548415261309 li {margin-left:
<ul class="toc-indentation"><li><a
href="#FormsandValidation-CustomizingValidationMessagesforBeanEditForm">Customizing
Validation Messages for BeanEditForm</a></li></ul>
</li><li><a
href="#FormsandValidation-ConfiguringValidatorContraintsintheMessageCatalog">Configuring
Validator Contraints in the Message Catalog</a></li><li><a
href="#FormsandValidation-ValidationMacros">Validation Macros</a></li><li><a
href="#FormsandValidation-OverridingtheTranslatorwithEvents">Overriding the
Translator with Events</a></li></ul>
</li></ul></div><h1 id="FormsandValidation-TheFormComponent">The Form
Component</h1><p>The core of Tapestry's form support is the <a
class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Form.html">Form</a>
component. The Form component encloses (wraps around) all the other <em>field
components</em> such as <a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/TextField.html">TextField</a>,
<a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/TextArea.html">TextArea</a>,
<a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Checkbox.html">Checkbox</a>,
etc.</p><h2 id="FormsandValidation-FormEvents">Form Events</h2><p>The Form
component emits a number of <a href="component-events.html">component
events</a>. You'll want to provide event handler m
ethods for some of these.</p><p>When rendering, the Form component emits two
events: first, "prepareForRender", then "prepare". These allow the Form's
container to set up any fields or properties that will be referenced in the
form. For example, this is a good place to create a temporary entity object to
be rendered, or to load an entity from a database to be edited.</p><p>When user
submits the form on the client, a series of steps occur on the
server.</p><p>First, the Form emits a "prepareForSubmit" event, then a
"prepare" event. These allow the container to ensure that objects are set up
and ready to receive information from the form submission.</p><p>Next, all the
fields inside the form are <em>activated</em> to pull values out of the
incoming request, validate them and (if valid) store the changes.</p><div
class="navmenu" style="float:right; width:25%; background:#eee; margin:3px;
padding:3px">
-<p><em>For Tapestry 4 Users:</em> Tapestry 5 does not use the fragile "form
rewind" approach from Tapestry 4. Instead, a hidden field generated during the
render stores the information needed to process the form
submission.</p></div> <p><br clear="none"></p><p>After the fields have
done their processing, the Form emits a "validate" event. This is your chance
to perform any cross-form validation that can't be described
declaratively.</p><p>Next, the Form determines if there have been any
validation errors. If there have been, then the submission is considered a
failure, and a "failure" event is emitted. If there have been no validation
errors, then a "success" event is emitted.</p><p>Finally, the Form emits a
"submit" event, for logic that doesn't care about success or failure.</p><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Form Event (in order)</p></th><th
colspan="1" rowspan="1" class="confluenceTh"><p>P
hase</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>When emitted
(and typical use)</p></th><th colspan="1" rowspan="1"
class="confluenceTh">Method Name</th><th colspan="1" rowspan="1"
class="confluenceTh">@OnEvent Constant</th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>prepareForRender</strong></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Render</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Before rendering the form (e.g. load an
entity from a database to be edited)</p></td><td colspan="1" rowspan="1"
class="confluenceTd">onPrepareForRender()</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.PREPARE_FOR_RENDER</td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><strong>prepare</strong></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Render</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Before rendering the form, but after
<em>prepareForRender</em></p></td><td c
olspan="1" rowspan="1" class="confluenceTd">onPrepare()</td><td colspan="1"
rowspan="1" class="confluenceTd">EventConstants.PREPARE</td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><strong>prepareForSubmit</strong></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Before the submitted form is
processed</p></td><td colspan="1" rowspan="1"
class="confluenceTd">onPrepareForSubmit()</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.PREPARE_FOR_SUBMIT</td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><strong>prepare</strong></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Before the submitted form is processed, but after
<em>prepareForSubmit</em></p></td><td colspan="1" rowspan="1"
class="confluenceTd">onPrepare()</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.PREPA
RE</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>validate</strong></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>After fields have been populated from submitted values
and validated (e.g. perform cross-field validation)</p></td><td colspan="1"
rowspan="1" class="confluenceTd">onValidate</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.VALIDATE</td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>validateForm</strong></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>same as <em>validate (deprecated – do
not use)<br clear="none"></em></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><em>onValidateForm</em></td><td colspan="1" rowspan="1"
class="confluenceTd"> </td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>failure</stro
ng></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Submit</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>After one or more validation errors have
occurred</p></td><td colspan="1" rowspan="1"
class="confluenceTd">onFailure()</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.FAILURE</td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>success</strong></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>When validation has completed
<em>without</em> any errors (e.g. save changes to the database)</p></td><td
colspan="1" rowspan="1" class="confluenceTd">onSuccess()</td><td colspan="1"
rowspan="1" class="confluenceTd">EventConstants.SUCCESS</td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><strong>submit</strong></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p
>After all validation (success or failure) has finished</p></td><td
>colspan="1" rowspan="1" class="confluenceTd">onSubmit()</td><td colspan="1"
>rowspan="1" class="confluenceTd">EventConstants.SUBMIT</td></tr><tr><td
>colspan="1" rowspan="1"
>class="confluenceTd"><strong>canceled</strong></td><td colspan="1"
>rowspan="1" class="confluenceTd">Submit</td><td colspan="1" rowspan="1"
>class="confluenceTd">Whenever a <em>Submit</em> or <em>LinkSubmit</em>
>component containing <em>mode="cancel"</em> or <em>mode="unconditional"</em>
>is clicked</td><td colspan="1" rowspan="1"
>class="confluenceTd">onCanceled()</td><td colspan="1" rowspan="1"
>class="confluenceTd">EventConstants.CANCELED</td></tr></tbody></table></div><p>Note
> that the "prepare" event is emitted during both form rendering and form
>submission.</p><h2 id="FormsandValidation-HandlingEvents">Handling
>Events</h2><p>Main Article: <a href="component-events.html">Component
>Events</a></p><p>You handle events by providing methods in your pag
e or component class, either following the
on<strong><em>Event</em></strong>From<strong><em>Component</em></strong>()
naming convention or using the OnEvent annotation. For example:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Event Handler Using
Naming Convention</b></div><div class="codeContent panelContent pdl">
+<p><em>For Tapestry 4 Users:</em> Tapestry 5 does not use the fragile "form
rewind" approach from Tapestry 4. Instead, a hidden field generated during the
render stores the information needed to process the form
submission.</p></div> <p><br clear="none"></p><p>After the fields have
done their processing, the Form emits a "validate" event. This is your chance
to perform any cross-form validation that can't be described
declaratively.</p><p>Next, the Form determines if there have been any
validation errors. If there have been, then the submission is considered a
failure, and a "failure" event is emitted. If there have been no validation
errors, then a "success" event is emitted.</p><p>Finally, the Form emits a
"submit" event, for logic that doesn't care about success or failure.</p><div
class="table-wrap"><table class="confluenceTable"><colgroup span="1"><col
span="1"><col span="1"><col span="1"><col span="1"><col
span="1"></colgroup><tbody><tr><th colspan="1" rowspan="1" class="
confluenceTh"><p>Form Event (in order)</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Phase</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>When emitted (and typical use)</p></th><th colspan="1"
rowspan="1" class="confluenceTh">Method Name</th><th colspan="1" rowspan="1"
class="confluenceTh">@OnEvent Constant</th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>prepareForRender</strong></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Render</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Before rendering the form (e.g. load an
entity from a database to be edited)</p></td><td colspan="1" rowspan="1"
class="confluenceTd">onPrepareForRender()</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.PREPARE_FOR_RENDER</td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><strong>prepare</strong></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Render</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Before rendering the form, but after
<em>prepareForRender</em></p></td><td colspan="1" rowspan="1"
class="confluenceTd">onPrepare()</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.PREPARE</td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><strong>prepareForSubmit</strong></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Before the submitted form is
processed</p></td><td colspan="1" rowspan="1"
class="confluenceTd">onPrepareForSubmit()</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.PREPARE_FOR_SUBMIT</td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><strong>prepare</strong></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Before the submitted form is processed, but after
<em>prepareForSubmit</em></p></td><td colspan="1" rowspan="1" class=
"confluenceTd">onPrepare()</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.PREPARE</td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>validate</strong></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>After fields have been populated from
submitted values and validated (e.g. perform cross-field
validation)</p></td><td colspan="1" rowspan="1"
class="confluenceTd">onValidate</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.VALIDATE</td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>validateForm</strong></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>same as <em>validate (deprecated – do
not use)<br clear="none"></em></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><em>onValidateForm</em></td><td colspan="1" rowspan="1"
class="conflue
nceTd"> </td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>failure</strong></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>After one or more validation errors have
occurred</p></td><td colspan="1" rowspan="1"
class="confluenceTd">onFailure()</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.FAILURE</td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>success</strong></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>When validation has completed
<em>without</em> any errors (e.g. save changes to the database)</p></td><td
colspan="1" rowspan="1" class="confluenceTd">onSuccess()</td><td colspan="1"
rowspan="1" class="confluenceTd">EventConstants.SUCCESS</td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><strong>submit</strong></p></td><td colspan="1" ro
wspan="1" class="confluenceTd"><p>Submit</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>After all validation (success or failure) has
finished</p></td><td colspan="1" rowspan="1"
class="confluenceTd">onSubmit()</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.SUBMIT</td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><strong>canceled</strong></td><td colspan="1"
rowspan="1" class="confluenceTd">Submit</td><td colspan="1" rowspan="1"
class="confluenceTd">Whenever a <em>Submit</em> or <em>LinkSubmit</em>
component containing <em>mode="cancel"</em> or <em>mode="unconditional"</em> is
clicked</td><td colspan="1" rowspan="1"
class="confluenceTd">onCanceled()</td><td colspan="1" rowspan="1"
class="confluenceTd">EventConstants.CANCELED</td></tr></tbody></table></div><p>Note
that the "prepare" event is emitted during both form rendering and form
submission.</p><h2 id="FormsandValidation-HandlingEvents">Handling
Events</h2><p>Main Article: <a href="
component-events.html">Component Events</a></p><p>You handle events by
providing methods in your page or component class, either following the
on<strong><em>Event</em></strong>From<strong><em>Component</em></strong>()
naming convention or using the OnEvent annotation. For example:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Event Handler Using
Naming Convention</b></div><div class="codeContent panelContent pdl">
<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java;
gutter: false; theme: Default" data-theme="Default"> void
onValidateFromPassword() { ...}</pre>
</div></div><p>or the equivalent using @OnEvent:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Event Handler Using @OnEvent
Annotation</b></div><div class="codeContent panelContent pdl">
<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java;
gutter: false; theme: Default" data-theme="Default">
@OnEvent(value=EventConstants.VALIDATE, component="password")
@@ -217,7 +217,7 @@ public class Login {
</div></div><p> </p><h1 id="FormsandValidation-FormValidation"><span
style="color: rgb(83,145,38);">Form Validation</span></h1><p>The above example
is a very basic form which allows the fields to be empty. However, with a
little more effort we can add client-side validation to prevent the user from
submitting the form with either field empty.</p><p>Validation in Tapestry
involves associating one or more <em>validators</em> with a form element
component, such as TextField or PasswordField. This is done using the
<strong>validate</strong> parameter:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: xml;
gutter: false; theme: Default" data-theme="Default"><t:textfield
t:id="userName" validate="required" t:mixins="formgroup"/>
<t:passwordfield t:id="password" value="password" validate="required"
t:mixins="formgroup"/></pre>
-</div></div><h2 id="FormsandValidation-AvailableValidators"><span
style="color: rgb(83,145,38);">Available Validators</span></h2><p>Tapestry
provides the following built-in validators:</p><div class="table-wrap"><table
class="confluenceTable"><colgroup span="1"><col span="1"><col span="1"><col
span="1"><col span="1"></colgroup><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Validator</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Constraint Type</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Example</p></th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>email</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>–</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Ensures that the given input looks like a valid e-mail
address</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="userEmail" validate="ema
il" /></code></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>max</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>long</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Enforces a maximum integer value</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code><t:textfield
value="age" validate="max=120,min=0" /></code></p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p>maxLength</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>int</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Makes sure that a string value has a
maximum length</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="zip"
validate="maxlength=7" /></code></p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>min</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>long</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Enforces a minimum integer value</
p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="age"
validate="max=120,min=0" /></code></p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>minLength</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>int</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Makes sure that a string value has a minimum
length</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="somefield"
validate="minlength=1" /></code></p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>none</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>–</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Does nothing (used to override a @Validate
annotation)</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="somefield" validate="none"
/></code></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>regexp</p></td><td c
olspan="1" rowspan="1" class="confluenceTd"><p>pattern</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Makes sure that a string value conforms to
a given pattern</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="letterfield"
validate="regexp=^</code><code>[A-Za-z]+$" /></code></p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p>required</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>–</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Makes sure that a string value is not null
and not the empty string</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="name" validate="required"
/></code></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">checked <em>(Since 5.4.5)</em></td><td colspan="1"
rowspan="1" class="confluenceTd">boolean</td><td colspan="1" rowspan="1"
class="confluenceTd">Makes sure that the boolean is true (checkbox is che
cked)</td><td colspan="1" rowspan="1" class="confluenceTd"><t:Checkbox
value="value" validate="checked" /></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">unchecked <em>(Since 5.4.5)</em></td><td colspan="1"
rowspan="1" class="confluenceTd">boolean</td><td colspan="1" rowspan="1"
class="confluenceTd"><span>Makes sure that the boolean is false (checkbox is
unchecked)</span></td><td colspan="1" rowspan="1"
class="confluenceTd"><t:Checkbox value="value" validate="unchecked"
/></td></tr></tbody></table></div><h2
id="FormsandValidation-CentralizingValidationwith@Validate">Centralizing
Validation with @Validate</h2><p>The @<a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beaneditor/Validate.html">Validate</a>
annotation can take the place of the validate parameter of TextField,
PasswordField, TextArea and other components. When the validate parameter is
not bound in the template file, the component will check for the
@Validate annotation and use its value as the validation
definition.</p><p>The annotation may be placed on the getter or setter method,
or on the field itself.</p><p>Let's update the two fields of the Login
page:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><h2 id="FormsandValidation-AvailableValidators"><span
style="color: rgb(83,145,38);">Available Validators</span></h2><p>Tapestry
provides the following built-in validators:</p><div class="table-wrap"><table
class="confluenceTable"><colgroup span="1"><col span="1"><col span="1"><col
span="1"><col span="1"></colgroup><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Validator</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Constraint Type</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Example</p></th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>email</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>–</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Ensures that the given input looks like a valid e-mail
address</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="userEmail" validate="ema
il" /></code></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>max</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>long</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Enforces a maximum integer value</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code><t:textfield
value="age" validate="max=120,min=0" /></code></p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p>maxLength</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>int</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Makes sure that a string value has a
maximum length</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="zip"
validate="maxlength=7" /></code></p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>min</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>long</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Enforces a minimum integer value</
p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="age"
validate="max=120,min=0" /></code></p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>minLength</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>int</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Makes sure that a string value has a minimum
length</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="somefield"
validate="minlength=1" /></code></p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p>none</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>–</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Does nothing (used to override a @Validate
annotation)</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="somefield" validate="none"
/></code></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>regexp</p></td><td c
olspan="1" rowspan="1" class="confluenceTd"><p>pattern</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Makes sure that a string value conforms to
a given pattern</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="letterfield"
validate="regexp=^</code><code>[A-Za-z]+$" /></code></p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p>required</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>–</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Makes sure that a string value is not null
and not the empty string</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code><t:textfield value="name" validate="required"
/></code></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">checked <em>(Since 5.4.5)</em></td><td colspan="1"
rowspan="1" class="confluenceTd">boolean</td><td colspan="1" rowspan="1"
class="confluenceTd">Makes sure that the boolean is true (checkbox is che
cked)</td><td colspan="1" rowspan="1"
class="confluenceTd"><code><t:Checkbox value="value" validate="checked"
/></code></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">unchecked <em>(Since 5.4.5)</em></td><td colspan="1"
rowspan="1" class="confluenceTd">boolean</td><td colspan="1" rowspan="1"
class="confluenceTd"><span>Makes sure that the boolean is false (checkbox is
unchecked)</span></td><td colspan="1" rowspan="1"
class="confluenceTd"><code><t:Checkbox value="value" validate="unchecked"
/></code></td></tr></tbody></table></div><h2
id="FormsandValidation-CentralizingValidationwith@Validate">Centralizing
Validation with @Validate</h2><p>The @<a class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beaneditor/Validate.html">Validate</a>
annotation can take the place of the validate parameter of TextField,
PasswordField, TextArea and other components. When the validate parameter is
not bound in the template file, the co
mponent will check for the @Validate annotation and use its value as the
validation definition.</p><p>The annotation may be placed on the getter or
setter method, or on the field itself.</p><p>Let's update the two fields of the
Login page:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java;
gutter: false; theme: Default" data-theme="Default"> @Persist
@Property
@Validate("required")