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