Quantcast
Channel: Developer Express Inc.
Viewing all articles
Browse latest Browse all 2370

UI Annotation using Business Rules

$
0
0

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.

image

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:

image

When the Validation occurs this implementation will not raise exceptions for Warning and Information Rules and will change their notification icon accordingly.

Windows

image

Web

image

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?

  1. Download  RuleType.zip and open it VS.
  2. 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).

    image
  3. 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).

Subscribe to XAF feed
Subscribe to community feed


Viewing all articles
Browse latest Browse all 2370

Trending Articles