Getting started with Reusable Modules

From Wiki

Jump to: navigation, search

Introduction

The reusable modules are a new feature available starting from the WebRatio 5.1 version.

A reusable module is a new Web Model concept that allows you to create patterns and use them everywhere in your Web Project without having to copy all the pattern but just referencing it. The main advantages are:

  • Maintanance Facility. It's possible to easily change the pattern if there are mistakes or you simply want to modify it. If the pattern is replicated everywhere you want to use it in the project, you would have to search each point in which the pattern is placed and replicate the change. Using modules you "centralize" the logic in one point (the module itself) and you have to make changes only in one place, saving time and other errors.
  • Web Model Readability. Using modules you can orient yourself better navigating the Web Model. When you deal with big projects you often have a complex Web Models with many units and pages and finding something in it may become difficult even using the predefined searches. Moreover you can hardly remember what a complex operation chain does; instanciating a module and giving a name to it clears better what's the purpose of the module and helps you understand and read better the Web Model itself.

Working with Reusable Modules

There are three different modules types:

  • Image:contentModule.png Content Module. It's a collection of content units that can be used as portion of the content of Web Model pages. In this type of module you can use subpages and alternatives.


  • Image:operationModule.png Operation Module. You can group into this module operation chains accomplishing a specific function (e.g. the user creation). You can define operation groups and transactions and you can also use other operation module instance inside a module.


  • Image:hybridModule.png Hybrid Module. It's a collection of pages, operation units and operation groups. It can be very useful when you want to model the same feature (e.g. the visualization of a PDF report) in different places. In this way you can model the feature the first time in the module and then instanciate it where you want to use it.

Once defined, a module can be placed and used in site views and service views acting as a unit filled with input and output parameters.

Modules can be created in their own View called Module View. In order to add a new Module View in your Web Project you have to

  1. Select the Project tab and click on the Module View Image:moduleView.png button. Alternatively you can right click in the work area and choose the Add Module View command.
  2. In the opening dialog type the name of the Module View and click on the Finish button.

In the Module View the left side palette shows some new tools, corresponding to the new units that you have to know in order to create a new module from scratch properly.

  • Input Collector Unit. It's the entry point of a module and groups all the Input Parameters necessary to the module in order to work properly. It's both a Content and Operation unit. In order to specify the Input Parameters on the unit you have to explicitely add Input Collector Parameters. To do this right click on the unit and choose the Add Input Collector Parameter command.




  • OK Collector Unit. It's the exit point of an operation module and groups all the Output Parameters that the modules provides to the other units in the Web Model. It's an Operation unit and it represents the case in which the execution of the module ends with success. You can define Output Parameters on the unit right clicking on it and choosing the Add Output Collector Parameter command. Moreover it's possible to define OK link Cases, like for the Switch Unit, using different OK Collector Units in the same module.


  • KO Collector Unit. It's the exit point of an operation module and groups all the Output Parameters that the modules provides to the other units in the Web Model. It's an Operation unit and it represents the case in which the execution of the module ends with error. You can define Output Parameters on the unit right clicking on it and choosing the Add Output Collector Parameter command. Moreover it's possible to define KO link Cases, like for the Switch Unit, using different KO Collector Units in the same module.



  • Output Collector Unit. It's the exit point of an content module and groups all the Output Parameters that the modules provides to the other units in the Web Model. It's a Content Unit and it represents the case in which the execution of the module ends. You can define Output Parameters on the unit right clicking on it and choosing the Add Output Collector Parameter command.





  • Module Instance Unit. It permits to execute a module defined in a Module View. It's both a Content and an Operation unit and can be placed in a Site View, Service View or Module View.

Transforming a Web Model portion into a Module

Let's see how to create modules starting from an existing project created with the 5.0 version of WebRatio. The procedure to follow is the same for every module type. We can use the WebRatio Sample project called BookStore. If you do not have this project you can download it from the main menu selecting Help -> WebRatio Samples and choosing in the opening dialog the BookStore project.

Open the WebRatio BookStore Site View and search the "Book Page". We want to transform the operation chain shown in the figure on the right into an Operation Module. To do this you have to:


  1. Select all the units belonging to the operation chain.
  2. Right click and choose the Transform into Module command.
  3. Choose the name of the Module View (this step is available only if there is no Module View in the Web Project). The click on the Next button.
  4. Choose the name of the Operation Module and the name of the Module Instance Unit that will replace the operation in the operation chain. Click on the Finish button.




You can see the final result in the following figures

Image:Module.png

Let's see an example of Content Module. Consider the "Leave a comment" page. In this page there are a MultiDataUnit, DataUnit and an IndexUnit. These same units are also pleaced in the "Customer's comments of this book". We can transform those units into a Content Module just we have done before. This is the result.

Image:Module2.png

We can substitute the content module to the units also in the "Customer's comments of this book" page. These are the steps to follow:

  1. Add a Module Instance Unit to the page and name it "Book Details"
  2. In the Properties View choose the Content Module created in the previous example
  3. Add all the links outgoing from the units replaced by the module and copy the Collector Code from the "Leave a comment" page
  4. Move the target of the link incoming the page on the Module Instance Unit and restore the correct coupling.
  5. Delete the units replaced by the module instance from the page.
Personal tools