Author: drobiazko
Date: Thu Oct 22 19:42:08 2009
New Revision: 828827
URL: http://svn.apache.org/viewvc?rev=828827&view=rev
Log:
TAP5-895: Tracking issue for Tapestry/JSR-303 integration
Added:
tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/
tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/
tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/conf.apt (with props)
tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/index.apt (with props)
tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/userguide.apt (with props)
tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/site.xml (with props)
Added: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/conf.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/conf.apt?rev=828827&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/conf.apt (added)
+++ tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/conf.apt Thu Oct 22 19:42:08
2009
@@ -0,0 +1,45 @@
+ ----
+ Configuration
+ ----
+
+Configuring Bean Validator
+
+ The Tapestry Bean Validator Library is responsible for configuring and bootstrapping the
<<javax.validation.Validator>> for you.
+ In order to use this library you have to choose an implementation of the JSR-303 specification
like {{{https://www.hibernate.org/412.html}Hibernate Validator 4.x}}.
+ This library is not specific to any implementation of JSR-303 and will work with any implementation
of your choice.
+
+* Bootstraping the Bean Validator
+
+ The service {{{../apidocs/org/apache/tapestry5/beanvalidator/BeanValidatorSource.html}BeanValidatorSource}}
is responsible for
+ bootstrapping the <<javax.validation.Validator>>. You can contribute a {{{../apidocs/org/apache/tapestry5/beanvalidator/BeanValidatorConfigurer.html}BeanValidatorConfigurer}}
+ to the configuration of this service in order to participate on the configuration of <<javax.validation.Validator>>.
+
++----+
+public static void contributeBeanValidatorSource(OrderedConfiguration<BeanValidatorConfigurer>
configuration)
+{
+ configuration.add("MyConfigurer", new BeanValidatorConfigurer()
+ {
+ public void configure(javax.validation.Configuration<?> configuration)
+ {
+ configuration.ignoreXmlConfiguration();
+ }
+ });
+}
++----+
+
+* Validation groups
+
+ In JSR-303 validation groups are used you to define a subset of the constraints validated
at a given time. If no validation group is specified
+ the default group <<javax.validation.groups.Default>> is taken. Per default
Tapestry passes only this group to <<javax.validation.Validator>>.
+ You can tell Tapstry pass more groups by contributing group classes into the configuration
of the service {{{../apidocs/org/apache/tapestry5/beanvalidator/BeanValidatorGroupSource.html}BeanValidatorGroupSource}}.
+
++----+
+public static void contributeBeanValidatorGroupSource(Configuration<Class> configuration)
+{
+ configuration.add(MyGroup.class);
+}
++----+
+
+* Limitations
+
+ This library does not provide clientside validation yet.
Propchange: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/conf.apt
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/index.apt?rev=828827&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/index.apt (added)
+++ tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/index.apt Thu Oct 22 19:42:08
2009
@@ -0,0 +1,12 @@
+ ----
+ About Tapestry/JSR-303 Integration
+ ----
+
+Tapestry/JSR-303 Integration
+
+ Tapestry provides a powerful validation mechanism which is described {{{../guide/validation.html}here}}.
Among other things this
+ mechanism allows you to annotate your domain model classes with the annotation {{{../apidocs/org/apache/tapestry5/beaneditor/Validate.html}@Validate}}.
+ This annotation is problematic if your domain model is used in non-Tapestry applications
as well as in Tapestry applications. Your non-Taoestry application
+ becomes dependent on {{{../tapestry5-annotations/}tapestry5-annotations}}. To make your
domain model independent from Tapestry you can use the {{{http://jcp.org/en/jsr/detail?id=303}JSR-303}}.
+ This library provides integration between Tapestry and JSR-303.
+
Propchange: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/index.apt
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/userguide.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/userguide.apt?rev=828827&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/userguide.apt (added)
+++ tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/userguide.apt Thu Oct 22
19:42:08 2009
@@ -0,0 +1,73 @@
+ ----
+ User Guide
+ ----
+
+Validating Input Fields
+
+ After you included this library into your web app, you may use the JSR-303 annotations
to validate the user's input.
+ The JSR-303 annotations may even be combined with Tapestry's built-in annotation @Validate.
+
++----+
+public class Login
+{
+ @NotNull
+ @Property @Persist
+ private String userName;
+
+ @NotNull
+ @Validate("minlength=10")
+ @Property @Persist
+ private String password;
+
+ void onSuccess()
+ {
+ // Login the user here
+ }
+}
++----+
+
+ Next you have to pass the object to validate into the Form's parameter <<validate>>.
In the following example the Form's fields are bound to
+ the properties of the page <<Login>>. That's why we pass <<this>>,
thus the page instance, into the parameter <<validate>>.
+ Since the parameter <<validate>> defaults to the container of the Form component,
we can also remove <<validate="this">> in this example.
+
++----+
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
+ <body>
+ <t:form validate="this">
+
+ <t:errors/>
+
+ <p>
+ <t:textfield t:id="userName"/>
+ </p>
+
+ <p>
+ <t:textfield t:id="password"/>
+ </p>
+
+ <p>
+ <input type="submit" value="Login"/>
+ </p>
+ <t:form>
+ </body>
+</html>
++----+
+
+Validating Beans with BeanEditForm
+
+ If you use the <<BeanEditForm>> it is even easier to validate your beans. The
only thing you have to do is to annotate your beans with JSR-303 annotations.
+ If you move from Tapestry's built-in validation mechanism to JSR-303 Bean Validation, you
don't have to change your template at all.
+
++----+
+public class User
+{
+ @NotNull
+ private String userName;
+
+ @NotNull
+ @Validate("minlength=10")
+ private String password;
+
+ ...
+}
++----+
\ No newline at end of file
Propchange: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/apt/userguide.apt
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/site.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/site.xml?rev=828827&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/site.xml (added)
+++ tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/site.xml Thu Oct 22 19:42:08
2009
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Copyright 2009 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project name="Tapestry/JSR-303 Integration Library">
+ <bannerLeft>
+ <name>Tapestry 5</name>
+ <href>http://tapestry.apache.org/tapestry5/</href>
+ <src>images/tapestry_banner.gif</src>
+ </bannerLeft>
+ <bannerRight>
+ <name>Apache</name>
+ <href>http://www.apache.org</href>
+ <src>images/asf_logo_wide.gif</src>
+ </bannerRight>
+ <skin>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>maven-skin</artifactId>
+ <version>1.1</version>
+ </skin>
+
+ <publishDate format="dd MMM yyyy"/>
+ <version/>
+
+ <body>
+
+ <menu ref="parent"/>
+
+ <menu name="Quick Links">
+ <item name="About" href="index.html"/>
+ <item name="Configuration" href="conf.html"/>
+ <item name="User guide" href="userguide.html"/>
+ <item name="Download" href="http://tapestry.apache.org/download.html"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Propchange: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/site.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tapestry/tapestry5/trunk/tapestry-beanvalidator/src/site/site.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
|