as mentioned within the previous post:
sev-en has
zero required
configuration and offers some powerful features such as
cross-component validation and extensibility (e.g.:
easy custom validation).
the following part illustrates some of these features.
the example uses facelets and trinidad. however, these technologies are
not required!
(sev-en supports property and field access.)
sample scenario - the target:=> first name != last name
=> birthday is (of course) before the final exam
=> old nick name != new nick name (with a direct reference to the old value)
=> old password != new password (without a direct reference to the old value)
=> new password == re-entered new password
=> each input-field is required (within the domain model: re-use
jpa annotations)
=> restrict the max. length of string values (also re-use information of jpa annotations)
now hold on a moment and think about the effort of doing such validations.
without sev-en:the simple parts of the scenario above can be solved with the according tags. if you are using jpa annotations, you already have some of these information within your mapping. ->
redundancy (annotations + tags).
ok - let's have a look at the more complex validation scenarios. i'm referring to the date and password validations. there might be e.g. some password components available. does your component lib offer such a feature? ok - nice, if you are one of the lucky one's. however, what's about the next complex requirement within your project? - there might be no adequate component within the available component libs.
or are you using one of the
unaesthetic workarounds?
sev-en provides a lot of powerful solutions.
using sev-en:the registration page:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixbqnXFly00LHLFw0HUp0eUKm0dv265OA_BZiXtp8bzRDRhTfi3nXUGxB5oUwGlyg17rzFr7UxbdTehkdQ9bTLOJaeToCcOdgnywcrF6W50Svrl1W5zLTPqCDBoBc3wKyadgbWTjsErFk/s400/registration-page.png)
the page to change the nick name:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTlzFuLS4KrjZDOmv5YqCaeim7Tl1jShx-cMVYaKIeM5fZFWZSwksu2x3pCDZB51W8RcjZWsFmzmCvkMkRToKY1atPtBYXxQb0n37mH8hSMfDwYK-qYLsUN1HxenydMx5QULVmf0q_ukg/s400/change-nickName-page.png)
the page to change the password:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzY006T-jjlcs0JaTFaB4SotJG43qZR3pfMgcOrHYgwgsigRD7o1mY_AWw5gweuJ-5jN9RbbWNZjkOunx7qDCMTKQA5ej3cqk2BmxlE6jOaaYbG3CypFA1axQD2y34sZcV4DCnJ3N0rO8/s400/change-password-page.png)
... oh - it's really straightforward!
the page bean class (backing bean):
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7e7L8po2LCK5XPr7grhPxn9hDFv82GUyfWJUKX7ToXGVUrYGZLeq6kTW9TokM44ei8wZRopmJskuibvVj9h1SClc-xRY6vaeI2voUOUMIG8lzCvPXjQqapp0Op_O_X8HshB68Q4VGuVA/s400/page-bean-class.png)
... oh - some new annotations - however, it's also really straightforward!
we aren't using jpa annotations here (it's the view layer!)
the domain model class:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjo6ws90k7-DhTsS3qefj9mixJNzoY40hWhsY68Esdf8ULtssC619ZyUrVS2PGZ24Inotns5u1OpSjULqJiLZpQmmab5uCDTLKwdCJy05-1mglKhdtBH_W-JHs0QPF5wzhzyrPrOpPlCQ8/s400/domain-class.png)
... really nice - some simple jpa annotations which are also used for validation.
you aren't using jpa? no problem - you can use conventional validation and/or you can use the sev-en standard or custom annotations ;)
the following screenshot shows an example of a failed validation:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPRh6O9GxlZBBmLBjfDzEg2ZUcrHdz5IePHdw59rzY76vQCq7MxdBQGLcNX4cWy6KyWhrBXfd05JIXMXZcAv0kYUQYstZThcbo6afKCzRe_IHtngCxA7IfzP7dRgcK3Kkjg9rBKoMT74Q/s320/03.png)
sev-en isn't about specific annotations. sev-en is mainly the core itself. out-of-the-box sev-en will provide some separated modules with nice annotations.
one of the next posts will be about the really easy way to implement custom sev-en annotations.