All docs
V20.2
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Reuse Implemented Functionality

  • 2 minutes to read

This topic describes how to add extra modules and business objects from an external library to extend the application's functionality.

XAF Extra Modules

Follow the steps below to add the Validation module and set up validation rules for business objects.

  1. In the Solution Explorer, right-click the SimpleProjectManager.Module.Blazor project and select Manage NuGet Packages. In the invoked NuGet Package Manager, choose the DevExpress 20.2 Local package source and install the DevExpress.ExpressApp.Validation and DevExpress.ExpressApp.Validation.Blazor NuGet packages.

    Add the NuGet Package to the shared project

  2. Open the SimpleProjectManager.Module.Blazor\Module.cs file and add the following code to the Module constructor:

    using DevExpress.ExpressApp.Validation;
    // ...
    namespace SimpleProjectManager.Module.Blazor {
        public sealed partial class SimpleProjectManagerBlazorModule : ModuleBase {
            public SimpleProjectManagerBlazorModule() {
                // ...
                RequiredModuleTypes.Add(typeof(ValidationModule));
            }
        }
    }
    
  3. Open the SimpleProjectManager.Module\BusinessObjects\Planning.cs file and apply the RuleCriteriaAttribute to the ProjectTask class:

    using DevExpress.Persistent.Validation;
    // ...
    [RuleCriteria("EndDate >= StartDate", 
        CustomMessageTemplate = "Start Date must be less than End Date")]
    public class ProjectTask : BaseObject {
        // ...
    }
    
  4. Run the Blazor application and create several project tasks. The added module validates project tasks according to the specified settings.

    Invalid values

Data Models from External Libraries

You can add a business class to your application from the Business Class Library. XAF generates UI elements according to this class' structure. The following steps show how to add the Person class from the Business Class Library and create the Employee navigation item to display Person objects in a list.

  1. Open the SimpleProjectManager.Module\Module.cs file and add the following code to the Module constructor:

    using DevExpress.Persistent.BaseImpl;
    // ...
    namespace SimpleProjectManager.Module {
        public sealed partial class SimpleProjectManagerModule : ModuleBase {
            public SimpleProjectManagerModule() {
                // ...
                AdditionalExportedTypes.Add(typeof(Person));
            }
        }
    }
    
  2. Invoke the Model Editor for the SimpleProjectManager.Module project and navigate to the NavigationItems | Items | Planning | Items node. Create a new navigation item and set its Caption property to "Employee" and View to "Person_ListView". Refer to the Add an Item to the Navigation Control topic for more information on how to add a navigation item.

    The new navigation item in the Model Editor

  3. Run the application. The navigation control shows the new item in the Planning section.

    The Person Detail and List Views

NOTE

You can also use third-party modules or create your own reusable modules for use in multiple XAF applications.

See Also