Template:ExampleSetUserLanguage

From WebRatio WebML Wiki

Jump to: navigation, search

Example {{{1}}} Set User Language

Our goal is to give to the user the possibility to set the language used to browse the Web 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 "User Details") and other properties in the Properties View (such as "Home" or "Landmark" properties) to make the page accessible.
  2. Add a Get Unit to the page: select the Get Unit icon from the palette and place it inside the page. Change the "Name" property in "Current User".
  3. Set the Context Parameter on which the Get Unit is based: click on the "Edit" button next to the "Context Parameter" property in the Properties View. Then choose the "UserCtxParam" Context Parameter from the opened dialog pane.
  4. 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 "User Details".
  5. 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 "User" 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 "username" and "email" attributes from the opened dialog.
  7. Draw a transport link between the "Current User" Get Unit and the "User Details" Data Unit: select the Link button from the palette and click on the "Current User" Get Unit (the Source of the Link) and then on the "User Details" Data Unit (the Target of the Link). Set the Name property of the newly created Link to "retrieve current user" and the Type property to "transport".
  8. Add an Selector Unit to the page: select the Selector Unit icon from the palette and place it inside the page. Change the "Name" property in "User's Language".
  9. 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 "Language" Entity from the opened dialog pane.
  10. Add the Condition for the user language: right click on the Selector Unit and choose "Add Relationship Role Condition" from the Context Menu. Select the newly added Condition from the Outline View and configure the properties as follow:
    • Name="user"
    • Role="UserToLanguage"
    • Predicate="In"
    • Required="True"
  11. Draw a transport link between the "User Details" Data Unit and the "User's Language" Selector Unit: select the Link button from the palette and click on the "User Details" Data Unit (the Source of the Link) and then on the "User's Language" Selector Unit (the Target of the Link). Set the Name property of the newly created Link to "retrieve user language" and the Type property to "transport".
  12. Add a Set Unit to the page: select the Set Unit icon from the palette and place it outside the page. Change the "Name" property in "Set Language".
  13. Set the Context Parameter on which the Set Unit is based: click on the "Edit" button next to the "Context Parameter" property in the Properties View. Then choose the "LanguageISOCtxParam and CountryISOCtxParam" Context Parameter from the opened dialog pane.
  14. Draw a transport link between the "User's Language" Selector Unit and the "Set Language" Set Unit : select the Link button from the palette and click on the "User's Language" Selector Unit (the Source of the Link) and then on the "Set Language" Set Unit (the Target of the Link). Set the Name property of the newly created Link to "set language" and the Type property to "transport".
  15. 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 "languageISOCode" Attribute of the Selector Unit with the "LanguageISOCtxParam" Context Parameter of the Set Unit and the "countryISOCode" Attribute of the Selector Unit with the "CountryISOCtxParam" Context Parameter of the Set Unit.
  16. 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 Get Unit
The Properties View of the Data Unit
The Properties View of the Selector Unit
The Properties View of the Set Unit
The coupling of the "Set language" transport link