|
Our goal is to give the possibility to the user to store new employees data in the application. The user will be able to define all the new employee data and save them in the Data Model.
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 "Insert a new Employee") 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 "Employee 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", "email", "birth date", "hire date" and "role" attributes. In order to choose the Company the new employee belongs to, select the "EmployeeToCompany [1:N]" Relationship Role.
- Add a Selector Unit to the page: select the Selector Unit icon from the palette and place it inside the page. Change the "Name" property in "All Companies".
- Set the Entity on which the Selector 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.
- Define the sort criteria of the Selector Unit: click on the "Edit" button next to the "Sort Attributes" property, then choose the "name" attribute and the "ascending" sort criteria.
- Draw a transport link between the "All Companies" Selector Unit and the "Employee Data" Entry Unit: select the Link button from the palette and click on the "All Companies" Selector Unit (the Source of the Link) and then on the "Employee Data" Entry Unit (the Target of the Link). Set the Name property of the newly created Link to "Companies data passing" and the Type property to "transport".
- 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 "oid" Attribute of the Selector Unit with the "Company [output]" Selection Field Slot of the Entry Unit and the "name" Attribute of the Selector Unit with the "Company [label]" Selection Field Slot of the Entry Unit.
- 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 "New Employee".
- Set the Entity on which the Data 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 Data Unit attributes from the opened dialog.
- Add a Create Unit: select the Create Unit icon from the palette and place it inside the Web Model. Change the "Name" property in "Create a new Employee".
- Set the Entity on which the Create 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.
- Draw a normal link between the "Employee Data" Entry Unit and the "Create a new Employee" Create 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 "Create a new Employee" Create Unit (the Target of the Link). Set the Name property of the newly created Link to "Save" 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, press the Guess Coupling button. WebRatio will automatically couple all the Input Parameters with the Output Parameters.
| The Guess Coupling functionality will perform a name comparison between Input and Output Parameters guessing possible coupling. It is particularly useful to use it with the Field Wizard functionality, since it will create the Fields with the same names of the Entity Attributes.
|
- Draw an OK link between the "Create a new Employee" Create Unit and the "New Employee" Data Unit: select the Link button from the palette and click on the "Create a new Employee" Create Unit (the Source of the OK Link) and then on the "New Employee" Data Unit (the Target of the OK Link). Set the Name property of the newly created OK Link to "Employee created".
- 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 "oid" Attribute of the Selector Unit with the "Company [output]" Selection Field Slot of the Entry Unit and the "name" Attribute of the Selector Unit with the "Company [label]" Selection Field Slot of the Entry 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 Selector Unit
|
The Parameters Coupling window of the transport link
|
The Properties View of the Data Unit
|
The Properties View of the Create Unit
|
The Parameters Coupling window of the normal link
|
The Parameters Coupling window of the OK link
|
|