Template:ExampleModifyEmployee

From WebRatio WebML Wiki

Jump to: navigation, search

Example {{{1}}}: Modify an Employee

Our goal is to give the possibility to the user to select and modify the data of an employee in the application. 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 "odify an Employee") and other properties in the Properties View (such as "Home" or "Landmark" properties) to make the page accessible.
  2. 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 "Employee List".
  3. 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 "Employee" Entity from the opened dialog pane.
  4. 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 "company" attributes from the opened dialog.
  5. Define the sort criteria of the Power Index Unit: click on the "Edit" button next to the "Default Sort Attributes" property, then choose the "surname" 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.
  6. Define the division of the Employee List in pages: select the Power Index Unit, set the "Block Factor" property to "10" and the "Block Window" property to "10".
  7. 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".
  8. 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 "oid", "name", "surname", "email", "birth date", "hire date" and "role" attributes. In order to modify the Company the employee belongs to, select the "EmployeeToCompany [1:N]" Relationship Role. Since all the Fields will be preloaded with the information of the selected employee, select the "Mark new fields as preloaded" checkbox.
  9. Hide the "oid" Field: expand the Entry Unit in the Outline View and select the Oid Field. In the Property View, select the "Hidden" property and deselect the "Modifiable" property.
  10. Draw a normal link between the "Employee List" Power Index Unit and the "Employee Data" Entry Unit: select the Link button from the palette and click on the "Employee List" Power Index 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 "Modify" and the Type property to "normal".
  11. 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 Power Index Unit with the "oid" Field of the Entry Unit,the "name" Attribute of the Power Index Unit with the "name" Field of the Entry Unit,the "surname" Attribute of the Power Index Unit with the "surname" Field of the Entry Unit,the "hire date" Attribute of the Power Index Unit with the "hire date" Field of the Entry Unit and the EmployeeToCompany.oid parameter (the primary key of the Companty the Employee is connected to) with the "Company - Preselection" Selection Field Slot.
  12. 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".
  13. 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.
  14. 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.
  15. 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".
  16. 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.
  17. 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 "Modified Employee".
  18. 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.
  19. 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.
  20. Add a Modify Unit: select the Modify Unit icon from the palette and place it inside the Web Model. Change the "Name" property in "Modify Employee".
  21. Set the Entity on which the Modify 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.
  22. Draw a normal link between the "Employee Data" Entry Unit and the "Modify Employee" Modify 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 "Modify Employee" Modify Unit (the Target of the Link). Set the Name property of the newly created Link to "Save" and the Type property to "normal".
  23. 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. Then couple the "oid" Field of the Entry Unit with the automatically created Key Condition of the Modify Unit {{Note|The Guess Coupling functionality will perform a name comparison between Input and Output Parameters guessing possible coupling. It is particulary useful to use it with the Field Wizard functionality, since it will create the Fields with the same names of the Entity Attributes.
  24. Draw an OK link between the "Modify Employee" Modify Unit and the "Modified Employee" Data Unit: select the Link button from the palette and click on the "Modify Employee" Modify Unit (the Source of the OK Link) and then on the "Modified Employee" Data Unit (the Target of the OK Link). Set the Name property of the newly created OK Link to "Employee modified".
  25. 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 Modify Unit with the automatically created Key Condition of the Data Unit
  26. 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 Power Index Unit
The Properties View of the Entry Unit
The "Modify" Link Parameters Coupling window
The Properties View of the Selector Unit
The "Companies data passing" Link Parameters Coupling window
The Properties View of the Data Unit
The Properties View of the Modify Unit
The "Save" Link Parameters Coupling window
The OK Link Parameters Coupling window
The generated Web application