Power Index Unit
From WebRatio WebML Wiki
Contents |
Introduction
The Power Index Unit is a Content Unit. Since it is an enhanced version of the Index Unit, it allows to display a list of Entity instances. Compared to the Index Unit, the Power Index Unit has the following features:
- Dynamic sort of the records choosing whether to sort one or more attributes ascending or descending.
- Multiple choice of elements of the list through the available checkbox.
- Multi-pages lists that allows to manage large lists (For example, the list of all the employees of a specific company).
In order to define the instances of the associated Entity to be retrieved, Selector Conditions can be used.
Properties
- Id: The unique key automatically assigned by WebRatio to identify the Unit (e.g. pwu1).
- Name: A meaningful name for the Unit, used as label (e.g. All employees).
- Entity: The Data Model Entity on which the Unit is based (e.g. employee).
- Display Attributes: The list of attributes representing the information shown for each row. The list of available attributes depends on the selected entity (e.g. Name, Surname, Age).
- Default Sort Attributes: The sort criteria list applied by default to the Unit. Each element of this list is composed by an attribute of the selected Entity and it's sort criteria (Ascending or Descending) (e.g. surname, ascending - which means alphabetical order). The position of the elements within the sort criteria list is relevant, since it defines the order in which they're applied.
- Sortable: A flag stating whether the list can be dynamically sorted by the user or not. The user can choose the actual sort criteria among the attributes specified in the "Default Sort Criteria" property
- Sort History Size: A numerical value specifying how many selected sort attributes must be remembered in the dynamic sorting criteria (default 1). If a Sort History Size greater than 1 is selected (e.g. 2), when the user chooses a sort criteria, all the previously selected (the number defined in the Sort History Size) sort criteria are taken into account as secondary sort criteria for sorting the list.
- Checkable: A flag stating whether the user can perform multiple choice of the rows or not.
- Block Factor: A numerical value specifying how many instances will be shown in the same page (e.g. 4). If the number of rows of the list is above the block factor, the list is splitted into several pages.
- Block Window: A numerical value specifying the maximum number of links available to jump to other result pages (e.g. 2).
- Max Results: A numerical value specifying the maximum number of the retrieved instances above which other instances are ignored by the Unit. If not specified, no row number limit is applied.
- Distinct: A flag stating that instances having duplicated attribute values have to be removed from the list. The attributes taken into account are those specified in the "Display Attributes" and "Default Sort Attributes" properties. Enabling this property means to automatically disable the "Cheackable" property, since the rows are no more uniquely identified.
- Link Order: The order of the outgoing links (if any) that will be applied to the links placed on each row of the list.
- Custom Descriptor: A flag stating that the Unit uses a Custom Descriptor.
Configuration
A Power Index 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:
- 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.
- Add Attributes Conditions: Adds an Attributes Condition to the Unit.
- Add Relationship Role Condition: Adds a Relationship Role Condition to the Unit.
- Add Pre Key Condition: Adds a Pre Key Condition to the Unit. This Condition behaves like a Key Condition but instead of filtering the shown instances, it defines the preselected rows. This option should be used only when the "Checkable" Property is enabled.
- Add Pre Attributes Condition: Adds a Pre Attributes Condition to the Unit. This Condition behaves like a Attributes Condition but instead of filtering the shown instances, it defines the preselected rows. This option should be used only when the "Checkable" Property is enabled.
- Add Pre Relationship Role Condition: Adds a Pre Relationship Role Condition to the Unit. This Condition behaves like a Relationship Role Condition but instead of filtering the shown instances, it defines the preselected rows. This option should be used only when the "Checkable" Property is enabled.
- Add Check Validation: Adds a Validation Rule that checks the number of checked items of the list (if the "Checkable" Property is enabled).
- Convert To: Opens a dialog in which it's possible to choose, among the compatible units, the one the Unit should be converted to.
Input and Output
The Input and the Output of the Unit are accessible through the Parameters Coupling window of incoming and outgoing Links respectively.
Input
The input of the Power Index 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 Power Index Unit. Here all the Conditions are listed.
Morevore, the Power Index Unit has some specific Input Parameters:
- Current Object: The set of key attributes values of the object that defines the current selected object (e.g. Current Oid).
- Block Factor: This Input Parameter behaves like the "Block Factor" Property, but the value can be dinamically set by the user during the navigation.
- Block Window: This Input Parameter behaves like the "Block Window" Property, but the value can be dinamically set by the user during the navigation.
- Block Index: A numerical value specifying the number of the result page where to jump.
Output
The output of the Power Index 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 Power Index Unit.
Here all the Output Parameters can be coupled with the Input Parameters of the target elements.
Moreover, the Power Index Unit has some specific Output Parameters:
- Checked Objects: The set of the primary keys of the checked rows. If an outgoing link uses this output parameter, it will be shown as a button (e.g. Checked Oid).
- oid (block): The list of the primary keys of all the items shown in the current result page.
- Block Index:A numerical value representing the index of the current result page.
Unit State Object
The Unit State Object for the Power Index Unit consists of the following properties:
- int dataSize: The number of the retrieved instances included within the current block
- Object[] data: The array of entity state objects of the retrieved instances included within the current block
- int currentIndex: The zero-based index of the entity state object of the current instance
- String currentSortAttribute: The current sorting attribute identifier (available if the unit is "Sortable"). Initially it can be null, and then all attributes are sorting attributes
- String currentSorting: The current sorting criteria (available if the unit is Sortable)
- Map sortMask: A map containing the sorting criteria ('A' or 'D') for each attribute identifier (available if the unit is Sortable)
- String[] {unitId}Checked: The array with the values of the primary kews of the pre-checked objects only (available if the unit is Checkable)
- String[] key: The array of the pipe-separated list of key attributes values of the entity (available if the unit is Checkable)
- Map scroller: The map containing the blocks information:
- first: The index of the first block of objects
- previous: The index of the previous block of objects
- next: The index of the next block of objects
- last: The index of the last block of objects
- current: The one-based index of the current block of objects
- blocks: The array of the bloks indexes
- from: The index of the first object included within the current block
- to: The index of the last object included within the current block
- of: The total number of objects
Examples
The purpose of this section is to show the usage of the Power Index Unit through examples. These examples are based on the Data Model shown in the following image.
| 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: Search of companies
|
Our goal is to give the possibility to the user to search among all the companies in the Data Model. The user will be able to see a list of all the companies in the Data Model and filter the list searching by name and nationality. In order to accomplish this example, it is necessary to go through the following steps:
|
|












