XAF already provides strong and flexible validation for any object that fits specified Rules with build-in the Validation Module. In this post you can find a sample XAF application which extends the Validation to provide support for Warning/Information messages.
The implementation uses any Validation Business Rule that exists in XAF’s Application Model. Below we see the default ones but its applicable to custom business rules as well.
The sample code extends the Application Model of IModelRuleBase and by using one more property like RuleType marks the rule as warning or information as shown:
When the Validation occurs this implementation will not raise exceptions for Warning and Information Rules and will change their notification icon accordingly.
Windows
Web
By default, it is also possible to create business rules that evaluated when an object is changed by using the ObjectSpaceObjectChanged custom context (see also Contextual Validation Concepts).
HOW TO APPLY THIS GREAT FUNCTIONALITY TO YOUR PROJECT?
- Download RuleType.zip and open it VS.
- Copy its only oneController which is located in RuleTypeController.cs and spanned across three modules to your own platform agnostic and platform depended modules (Win/Web).
- Hit F5 and profit!
Note: I “borrow” the code for RuleType support from our community project expandframework and for one more time we clearly see how flexible is XAF and how powerful to provide reusable solutions!
P.S.: The original eXpand implementation has code support using a RuleTypeAttribute as well as ListView support and can be found in Xpand.ExpressApp.Validation, Xpand.ExpressApp.Validation.Win and Xpand.ExpressApp.Validation.Web assemblies (See also this discussion in eXpand’s forums).
↧
UI Annotation using Business Rules
↧