How to: Create a Web Client Solution | How to: Create a Foundational Module | How to: Use and Register Services | How to: Add Module Pages to the Site Map | How to: Map Types for Dependency Injection | How to: Authorize Web Pages

How to: Create a Business Module

Business modules are units of development and deployment that typically include a combination of related Web pages, page flows, business logic, and services. You can use modules to encapsulate a set of concerns of your application and deploy them together. The following are examples of business modules:
  • A module that contains a specific application feature area, such as reports
  • A module that contains use cases around a specific back-end system, such as loan processing
This topic describes how to create a business module using the Add Business Module recipe of the Composite Web Client Automation.

Note:
The Composite Web Client Automation is not included in this bundle. For information about the Composite Web Client Automation, including download information, see Composite Web Client Automation on CodePlex.

Prerequisites

The Add Business Module recipe assumes that you have an existing Web client solution created with the Composite Web Client Automation. For information about how to create a Web client solution, see How to: Create a Web Client Solution.
The Add Business Module recipe applies to the Visual Studio solution folder (typically, this is the Modules solution folder).

Steps

The following procedure describes how to use the recipe to create a business module.

To use the Add Business Module recipe to create a business module
  • In Solution Explorer, right-click a solution folder, point to Web Client Factory, and then click Add Business Module (C#) or Add Business Module (Visual Basic), as shown in Figure 1.
AddBusinessModuleRecipeMenu.PNG
Figure 1
The Add Business Module recipe menu
  • (Optional) In the Add New Project dialog box, illustrated in Figure 2, change the name of the project in the Name box and the location of the project in the Location box.
AddBusinessModuleProjectTemplates.PNG
Figure 2
The Add Business Module project templates
  • Click OK. The recipe starts the Add Business Module Wizard. The options available in the wizard depend on the Web Client Solution template that you selected when you created the initial solution. Figure 3 illustrates the first page of the wizard as it appears if you selected the Web Client Solution (C#, Web Site) template.
AddBusinessModuleRecipeWizard-WebSiteProject.PNG
Figure 3
The Add Business Module recipe wizard for a Web Site Project solution
Figure 4 illustrates the first page of the wizard as it appears if you selected a Web Application project solution template.
AddBusinessModuleRecipeWizard-WebApplicationProject.PNG
Figure 4
The Add Business Module recipe wizard for a Web Application project solution
  • Under Web site, click the Web site where the module folder will be created (this folder will contain the Web pages for the module).
  • (Optional) If you want the module folder to have a different name than the module name, enter the new name in the text box for the folder name.
  • (Optional) If you created the Web client solution with the Web Application project template, you will see the Create a sub-Web Application Project check box. If you select this check box, the recipe creates a Web Application project in the folder for the Web pages.
  • (Optional) If you want a test project for the module to be created with test classes for your module components, select the Create project for unit tests check box.
  • (Optional) If you want to see a summary of the recipe actions and suggested next steps after the recipe completes, select the Show documentation after recipe completes check box.
  • Click Finish. The recipe generates the business module.

Outcome

You will have the following elements in your solution:
  • A C# class library project. This is the module class library. It contains a default view interface with a presenter, an empty folder named Services, a module initialization class, and a module controller.
  • A folder in the Web site with a default view implementation and a Web.config file. The Composite Web Application Block uses the module information in the Web.config file to load the module when the application starts.
  • (Optional) A test project for the module. This project includes unit tests for the module initialization class and the presenter class of the default view. It also includes a mock module controller you can use to test your presenters. Figure 5 illustrates a solution with a test project.
WebClientSolution.PNG
Figure 5
Web client solution with the business module Module1 and the test project Module1.Tests
If you select the Create as sub-Web Application Project option, the solution will contain the project for the Web Application project. Figure 6 illustrates a solution with a Web Application project.
WebClientSolution-2.PNG
Figure 6
Web client solution with a Web Application project for business module Module1

Next Steps

After you run the Add Business Module recipe, you are ready to perform one of the following steps:
  • Add master pages, pages, and user controls to the module. You can add these items implementing the Model-View-Presenter pattern by using the Add Master Page (with presenter), Add Page (with presenter), and Add User Control (with presenter) recipes.
  • Implement the module initializer. In the module initializer, you write code that will be executed when the application starts and loads the module. Typically, a module initializer performs the following tasks:
    • Registers module and global services. For more information related to registering and using services, see How to: Use and Register Services.
    • Exposes module features to the UI. By default, the Add Business Module recipe adds a module site map node to the site map. You can add more nodes if you want the user to be able to navigate directly to a particular page in the module. For more information about how to expose module features to the UI, see How to: Add Module Pages to the Site Map.
  • Implement module-specific business logic. Typically, business logic is implemented in the module controller and in services.
  • Implement navigation logic. Typically, navigation logic is implemented in the module controller. You can use the Page Flow Application Block to build complex page flows.
How to: Create a Web Client Solution | How to: Create a Foundational Module | How to: Use and Register Services | How to: Add Module Pages to the Site Map | How to: Map Types for Dependency Injection | How to: Authorize Web Pages

Last edited Jan 17, 2008 at 3:48 PM by siacomuzzi, version 3

Comments

No comments yet.