This article is not up to date and it has been substitute with new up to date content.

Please look the new up to date content.

Data Unit

by Mario Bruno
3,490 views Published on Oct 24, 2011
Applies to: All versions
Table of contents

Introduction

The Data Unit
The Data Unit

The Data Unit is a Content Unit used to display the information of a unique instance of a given Entity.

 

 

 

 

Properties

The Properties View of the Data Unit
The Properties View of the Data Unit
  • Id: The unique key automatically assigned by WebRatio to identify the Unit (e.g. dau5).
  • Name: A meaningful name for the Unit, used as label (e.g. Employee).
  • Entity: The Data Model Entity on which the Unit is based (e.g. employee).
  • Display Attributes: The list of attributes representing the information shown. The list of available attributes depends on the selected entity (e.g. Name, Surname, Age)
  • Link Order: The order of the outgoing links (if any)
  • Custom Descriptor: A flag stating that the Unit uses a Custom Descriptor.

 

 

 

 

 

 

 

 

Configuration

A Data Unit can be configured through a context menu that can be reached right clicking on the Unit either in the Work Area or in the Outline View. The context menu contains the following options:

The Context Menu of the Data Unit
The Context Menu of the Data Unit
  • Add Link: Adds an outgoing link to the Unit which can be used to transport information and eventually to activate different actions (such as adding new content to the page, reaching another page with new content, activating operation chains).
  • Add Property: Adds a custom property to the Unit. A Property is composed by Name and Value and permits to mark the element for different purposes.
  • Add Key Condition: Adds a Key Condition to the Unit. By default WebRatio adds a Key Condition to the Data Unit, but according to application requirements this Condition can be deleted or converted to another Condition.
  • Add Attributes Conditions: Adds an Attributes Condition to the Unit.
  • Add Relationship Role Condition: Adds a Relationship Role Condition to the Unit.

 

 

 

 

Input and Output

The Input and the Output of the Unit are accessible through the Parameters Coupling window of incoming and outgoing Links respectively.

Example of Input Parameters for the Data Unit
Example of Input Parameters for the Data Unit

 

Input

The input of the Data Unit consists of all the Conditions defined on the Unit. To access the input parameters, open the Parameters Coupling dialog with a double click or by selecting the "Coupling" property on an incoming link to the Data Unit. Here all the Conditions are listed.

Example of Output Parameters for the Data Unit
Example of Output Parameters for the Data Unit

 

 

 

 

 

 

 

 

Output

The output of the Data Unit consists of all the Attributes of the selected Entity representing the attributes values of the selected row. To access the Output Parameters, open the Parameters Coupling dialog with a double click or by selecting the "Coupling" property on an outgoing link from the Data Unit.

Here all the Output Parameters can be coupled with the Input Parameters of the target elements.

 

 

 

 

 

Unit State Object

The Unit State Object for the Power Index Unit consists of the following properties:

  • int dataSize: the number of entity state objects (zero or one)
  • Object data: the entity state object

 

Examples

The purpose of this section is to show the usage of the Data Unit through examples. These examples are based on the Data Model shown in the following image.


The Data Model used in the example
The Data Model used in the example
This Data Model consists of two Entities : "Company" and "Employee". The "Company" entity has many attributes, such as "Name", "E-mail", "Nationality", and so on. The "Employee" entity has attributes such as "Name", "Surname", "Email", "Role" and so on. An Employee belongs to one Company while, obviously, a Company has many Employees. This is represented with the 1:N Relationship "Company_Employee".

Example 1: Show a company

Our goal is to show in a page the information of a specific company. In order to accomplish this example, it is necessary to go through the following steps:
  1. Add a Page to the Site View: select the "Page" icon from the palette, and place it on the Site View. Change the page name (setting "Company information") and other properties in the Properties View (such as "Home" or "Landmark" properties) to make the page accessible.
  2. Add a Data Unit to the page: select the Data Unit icon from the palette and place it inside the page. Change the "Name" property in "Company Data".
  3. Choose which attributes of the selected Entity must be shown: click on the "Edit" button of the "Display Attributes" property. Then choose the "name", "logo", "website", "email", "nationality", "province" attributes from the opened dialog.
  4. Remove the automatically added Key Condition: expand the Data Unit from the Outline View and right click on the Key Condition. In the Context Menu select on "Delete" and confirm the operation.
  5. Add the Condition for the Company name definition: right click on the Data Unit and choose "Add Attributes Condition" from the Context Menu. Select the newly added Condition from the Outline View and configure the properties as follow:
    • Name="Company name"
    • Attributes="name"
    • Predicate="Equal"
    • Boolean Operator="Or"
    • Value="Web Models"
    • Required="True"
  6. Generate the Web application: click on "Generate Full Web Project" on the WebRatio Menu Bar. Once the generation process has completed, it is possible to start the application server and test the Web application.
The Web Model of the example
The Web Model of the example
The Properties View of the Data Unit
The Properties View of the Data Unit
The generated Web application
The generated Web application

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Example 2: The list of companies

Our goal is to show a list of all the companies and allow the user to select a company to see its details. In order to accomplish this example, it is necessary to go through the following steps:
  1. Add a Page to the Site View: select the "Page" icon from the palette, and place it on the Site View. Change the page name (setting "Companies") and other properties in the Properties View (such as "Home" or "Landmark" properties) to make the page accessible.
  2. Add an Index Unit to the page: select the Index Unit icon from the palette and place it inside the page. Change the "Name" property in "Company List".
  3. Set the Entity on which the Index Unit is based: click on the "Edit" button next to the "Entity" property in the Properties View. Then choose the "Company" Entity from the opened dialog pane.
    Nota
    Since we need to display all the companies contained in the Company Entity, we do not need to define Conditions, so that all instances of the Company Entity will be retrieved.
  4. Choose which attributes of the selected Entity must be shown: click on the "Edit" button of the "Display Attributes" property. Then choose the "Name" and "E-mail" attributes from the opened dialog.
  5. Define the sort criteria of the Index Unit: click on the "Edit" button next to the "Sort Attributes" property, then choose the "Name" attribute and the "ascending" sort criteria.
  6. Add a Data Unit to the page: select the Data Unit icon from the palette and place it inside the page. Change the "Name" property in "Company Detail".
  7. Set the Entity on which the Index Unit is based: click on the "Edit" button next to the "Entity" property in the Properties View. Then choose the "Company" Entity from the opened dialog pane.
  8. Choose which attributes of the selected Entity must be shown: click on the "Edit" button of the "Display Attributes" property. Then choose the all attributes from the opened dialog.
  9. Draw a normal link between the "Company List" Index Unit and the "Company Detail" Data Unit: select the Link button from the palette and click on the "Company List" Index Unit (the Source of the Link) and then on the "Company Detail" Data Unit (the Target of the Link). Set the Name property of the newly created Link to "View Details" and the Type property to "normal".
  10. Define the parameters coupling: open the Parameters Coupling window of the newly created link in order to define the coupling between the output parameters of the source Unit and the input parameters of the target Unit.In the Parameters Coupling dialog, couple the key attribute of the Index Unit with the Key Condition of the Data Unit. This will allow the user to select a company and see its details.
    Nota
    When the Target and the Source Unit are based on the same entity or on entities connected through a 1:N relationship, WebRatio is able to automatically set the coupling
  11. Generate the Web application: click on "Generate Full Web Project" on the WebRatio Menu Bar. Once the generation process has completed, it is possible to start the application server and test the Web application.
The Web Model of the example
The Web Model of the example
The Properties View of the Index Unit
The Properties View of the Index Unit
The Properties View of the Data Unit
The Properties View of the Data Unit
The Parameters Coupling window
The Parameters Coupling window
The generated Web application
The generated Web application

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Possible Enhancement

    Our goal is to show the list of all the employees related to the company that the user has selected to see its details. In order to accomplish this example, it is necessary to go through the following steps:
  1. Add an Index Unit to the page: select the Index Unit icon from the palette and place it inside the page. Change the "Name" property in "Employee List".
  2. Set the Entity on which the Index Unit is based: click on the "Edit" button next to the "Entity" property in the Properties View. Then choose the "Employee List" Entity from the opened dialog pane.
  3. Choose which attributes of the selected Entity must be shown: click on the "Edit" button of the "Display Attributes" property. Then choose the "Name", "Surname" and "E-mail" attributes from the opened dialog.
  4. Define the sort criteria of the Index Unit: click on the "Edit" button next to the "Sort Attributes" property, then choose the "Surname" attribute and the "ascending" sort criteria.
  5. Add the Condition for the Company selected: right click on the Index Unit and choose "Add Relationship Role Condition" from the Context Menu. Select the newly added Condition from the Outline View and configure the properties as follow:
    • Name="Employee Company"
    • Role="CompanyToEmployee"
    • Predicate="In"
    • Required="False"
  6. Draw a transport link between the "Company Details" Data Unit and the "Employee List" Index Unit: select the Link button from the palette and click on the "Company Details" Data Unit (the Source of the Link) and then on the "Employee List" Index Unit (the Target of the Link). Set the Name property of the newly created Link to "Details" and the Type property to "transport".
  7. Define the parameters coupling: open the Parameters Coupling window of the newly created link in order to define the coupling between the output parameters of the source Unit and the input parameters of the target Unit.In the Parameters Coupling dialog, couple the key attribute of the Data Unit with the Relationship Role Condition of the Index Unit. This will allow the user to see the list of employees related to the selected Company.
    Note
    When the Target and the Source Unit are based on the same entity or on entities connected through a 1:N relationship, WebRatio is able to automatically set the coupling.
  8. Generate the Web application: click on "Generate Full Web Project" on the WebRatio Menu Bar. Once the generation process has completed, it is possible to start the application server and test the Web application.
The Web Model of the enhancement example
The Web Model of the enhancement example
The Properties View of the Index Unit
The Properties View of the Index Unit
The Parameters Coupling window
The Parameters Coupling window
The generated Web application
The generated Web application

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
 

This article is not up to date and it has been substitute with new up to date content.

Please look the new up to date content.