myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Myfaces Wiki] Update of "Extensions/Validator/Getting Started/Constraint Aspects" by GerhardPetracek
Date Sun, 31 May 2009 17:38:57 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by GerhardPetracek:

  = Constraint Aspects/Parameters =
- == Overview ==
  This feature is available in MyFaces ExtVal in the 3rd release.[[BR]]
  Before the official release you can use it via the snapshot version.
+ == The Problem ==
+ {{{
+ //not typesafe:
+ @Required(parameters = {@Param(key= "severity", value = "warn", @Param(key= "display", value
= "global"))})
+ }}}
+ ... this version allows you to add general information to a constraint. You can think about
it as an extension point for constraints.
+ Constraint aspects allow to provide a typesafe alternative. So you can provide an ExtVal
add-on without knowing the concrete constraint implementation.[[BR]]
+ Only the add-on logic has to know what information might be available as parameter at the
constraint and how to use this information.[[BR]]
+ The final usage is quite easy (see the next example).
+ So you can have add-on-X which provides new features and constraints Y (they don't know
each other). but you can use the features of add-on-X with constraints Y (if they have an
attribute of the type Class<? extends ValidationParameter>[])
+ === How to use constraint parameters ===
+ Example usage of an ExtVal constraint + validation parameters:
+ {{{
+ @Required(parameters = {ViolationSeverity.Warn.class, DisplayGlobal.class})
+ }}}
+ '''that's it!!!'''
+ ----
+ Stop reading here if you don't like to implement a custom parameter or if you don't like
to query information of a parameter
+ ----
  Before you continue reading - constraint aspects don't replace "domain-attributes".[[BR]]
  E.g. the values of min and max of @Length are attributes of the constraint which might be
different at every usage.[[BR]]
@@ -17, +42 @@

  Constraint aspects allow you to extend the functionality of existing constraints.[[BR]]
  Furthermore, they allow to introduce shared features. The implementations to process the
information provided by the aspects/parameters aren't aware of the attribute name of the parameter
nor of the concrete type of the constraint, parameter,... That means you provide a generic
aspect attribute mechanism once and use it for different constraints and features.
- == Examples ==
+ == More Examples ==
- Example usage of an ExtVal constraint + validation parameters:
- {{{
- @Required(parameters = {ViolationSeverity.Warn.class, DisplayGlobal.class})
- }}}
  You can query the parameters of a constraint at any time.
  (You just need access to the constraint.)

View raw message