|
Our goal is to give the possibility to the user to search among all the employees in the Data Model. The user will be able to search for employees by name, surname and hire date.
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 Employees") 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 "Employees 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", "surname" and "hire date" attributes.
- 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 "Found Employees".
- 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" 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", "surname", "hire date" and "email" attributes from the opened dialog.
- 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.
- Add the Condition for the Name-based search: right click on the 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="Employee name"
-
Attributes="name"
-
Predicate="Begins With (Ignore Case)"
-
Boolean Operator="Or"
-
Value=""
-
Required="False"
- Add the Condition for the Surname-based search: right click on the 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="Employee surname"
-
Attributes="surname"
-
Predicate="Begins With (Ignore Case)"
-
Boolean Operator="Or"
-
Value=""
-
Required="False"
- Add the Condition for the Hire Date-based search: right click on the 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="Employee hire date"
-
Attributes="hire date"
-
Predicate="Less or Equal"
-
Boolean Operator="Or"
-
Value=""
-
Required="False"
- Set the Default Policy: expand the Index Unit in the Outline View and select the Selector sub-element. In the Property View set the "Default Policy" property to the "Empty(only with Not Required)" 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 "Employee Data" Entry Unit and the "Found Employees" Index Unit: select the Link button from the palette and click on the "Employee Data" Entry Unit (the Source of the Link) and then on the "Found Employees" Index Unit (the Target of the Link). Set the Name property of the newly created Link to "Search" 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 "Employee name" Attribute Condition of the Index Unit, the "surname" Field of the Entry Unit with the "Employee surname" Attribute Condition of the Index Unit, the "hire date" Field of the Entry Unit with the "Employee hire date" 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 Index Unit
|
The Parameters Coupling window
|
|