Power Index Unit

From WebRatio WebML Wiki

Jump to: navigation, search


Contents

Introduction

The Power Index Unit

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

The Power Index Unit Properties View
  • 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:

The Context Menu of the Power Index Unit
The Check Validation Rule Properties View
  • 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

Input configuration of the Power Index Unit

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

Output possibilities given by the Power Index Unit

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.

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: 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:

  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 "Search Companies") and other properties in the Properties View (such as "Home" or "Landmark" properties) to make the page accessible.
  2. Add an Entry Unit to the page: select the Entry Unit icon from the palette and place it inside the page. Change the "Name" property in "Company Data".
  3. Define the Entry Unit fields:right click on the Entry Unit and select the Field Wizard option. In the opened dialog pane, select the Employee Entity. In the next pane, select the "name" and "nationality" attributes.
  4. Add a Power Index Unit to the page: select the Power Index Unit icon from the palette and place it inside the page. Change the "Name" property in "Company List".
  5. Set the Entity on which the Power 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.
  6. Choose which attributes of the selected Entity must be shown: click on the "Edit" button of the "Display Attributes" property. Then choose the "name", "nationality", "website" and "email" attributes from the opened dialog.
  7. Define the sort criteria of the Power Index Unit: click on the "Edit" button next to the "Default Sort Attributes" property, then choose the "name" attribute and the "ascending" sort criteria. Since the Power Index Unit is dinamically sortable, set the "Sortable" property to true and the "Sort History Size" property to 1.
  8. Define the division of the Company List in pages: select the Power Index Unit, set the "Block Factor" property to "10" and the "Block Window" property to "10".
  9. Add the Condition for the Name-based search: right click on the Power Index 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="Begins With (Ignore Case)"
    • Boolean Operator="Or"
    • Value=""
    • Required="False"
  10. Add the Condition for the Nationality-based search: right click on the Power Index 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 nationality"
    • Attributes="nationality"
    • Predicate="Begins With (Ignore Case)"
    • Boolean Operator="Or"
    • Value=""
    • Required="False"
  11. Set the Default Policy: expand the Power Index Unit in the Outline View and select the Selector sub-element. In the Property View set the "Default Policy" property to the "Fill" value.
    Nota Setting the Default Policy to "Fill", with all the Conditions with the Required Property set False, means that by default the Unit will show all the employees. The "Empty" values means that at least one search criteria must be provided in order to populate the list
  12. Draw a normal link between the "Company Data" Entry Unit and the "Company List" Power Index Unit: select the Link button from the palette and click on the "Company Data" Entry Unit (the Source of the Link) and then on the "Company List" Power Index Unit (the Target of the Link). Set the Name property of the newly created Link to "Filter" and the Type property to "normal".
  13. 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 "name" Field of the Entry Unit with the "Company name" Attribute Condition of the Power Index Unit, the "nationality" Field of the Entry Unit with the "Company nationality" Attribute Condition of the Index Unit.
  14. 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 Properties View of the Entry Unit
The Properties View of the Power Index Unit
The Parameters Coupling window
The generated Web application



Related articles:
Category Difficulty Refers
Context Parameters Web Model Beginner Get Unit
Set Unit
Reset Unit
Create Unit Web Model Beginner Create Unit
Create a "Hello world" application Web Model Beginner Site View
WebML
WebRatio
Create a "Simple data centric" web application Web Model Beginner Site View
WebML
WebRatio
Custom Locations and Master pages Web Model Beginner Master Page
Custom Location
… further results












Did you find this article useful? Please rate it!

Rating: 0.0/5 (0 votes cast)

Personal tools