Introduction
The Multi Message Unit is a Content Unit that lets the user to print out messages within the page. The messages passed on the unit input links will be used instead of the message text or file specified on the unit. Within the messages is possible to use placeholders using the following syntax: $$placeholder-name$$ (e.g. $$FOO$$ baz $$BAR$$). To specify a multiple values separator for a certain placeholder is also possible to use the inline syntax: $$placeholder-name|separator$$.
Properties
The Properties View of the Multi Message Unit
-
Id: The unique key automatically assigned by WebRatio to identify the Multi Message Unit (e.g. mssu1p).
-
Name: A meaningful name for the Multi Message Unit, used as label (e.g. Result Message).
-
Message File: A file containing the message text. Useful in case of multiple units sharing the same text
-
Message Text: The message to be printed out
Configuration
A Multi Message Unit can be configured through a context menu that can be reached right clicking on the Unit either in the Work Area or in the Outline View. The context menu contains the following options:
The Context Menu of the Multi Message Unit
-
Add Link: Adds an outgoing link to the Unit which can be used to transport information and eventually to activate different actions (such as adding new content to the page, reaching another page with new content, activating operation chains).
-
Add -> Placeholder. Adds a placeholder to the Unit. Placeholder are used to dynamically compute the messages at runtime. The specific properties of the Placeholder are:
- Value: The default placeholder value.
- Value Separator: The separator value used to concatenate placeholder multiple values (default ", ").
-
Add -> Property: Adds a custom property to the Unit. A Property is composed by Name and Value and permits to mark the element for different purposes.
Input and Output
Example of Input Parameters for the Multi Message Unit
The Input and the Output of the Unit are accessible through the Parameters Coupling window of incoming and outgoing Links respectively. The input of the Multi Message Unit is composed of one input parameter for each placeholder added to the unit, in order to be able to set their values. Moreover a Shown Messages input parameter is available to pass a list of messages to be printed. The Unit does not have any output.
How to compose a message with Placeholders
In order to compose a message with the placeholders you simple need to enclose the name of each placeholder in $$ symbols, for example $$PlaceholderName$$. The $$PlaceholderName$$ will be replaced with a value computed at runtime.
Each placeholder becomes an Input Parameter of the Multi Message Unit, which can be coupled with an Output Parameter of a source unit, corresponding to the value to associate with the placeholder. In this way at runtime each $$PlaceholderName$$ will be replaced with the appropriate value.
Example of Input Parameters for the Multi Message Unit
Example
The purpose of this section is to show the usage of the Multi Message Unit through examples. These examples are based on the Data Model shown in the following image.
The Data Model used in the example
|
This Data Model consists of two Entities : "Company" and "Employee". The "Company" entity has many attributes, such as "Name", "E-mail", "Nationality", and so on. The "Employee" entity has attributes such as "Name", "Surname", "Email", "Role" and so on. An Employee belongs to one Company while, obviously, a Company has many Employees. This is represented with the 1:N Relationship "Company_Employee". |
Our goal is to show a customized message depending on the created employee. The name and the surname of the employee are the dynamic parts of the message, therefore two placeholders will be created.
The message of the Multi Message Unit should appear like this: “The employee $$employeeName$$ $$employeeSurname$$ has been created.”, where “employeeName” and “employeeSurname” are the names of the placeholders.
-
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 "Create an 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 "New employee".
-
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.
-
Add a Create Unit to the page: select the Create Unit icon from the palette and place it inside the page. Change the "Name" property in "Create 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 "New employee" Entry Unit and the "Create Employee" Create Unit: select the Link button from the palette and click on the "New employee" Entry Unit (the Source of the Link) and then on the "Create Employee" Create Unit (the Target of the Link). Set the Name property of the newly created Link to "Create" 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. |
-
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 "Result") and other properties in the Properties View (such as "Home" or "Landmark" properties) to make the page accessible.
-
Add a Multi Message Unit to the page: select the Multi Message Unit icon from the palette and place it inside the page. Change the "Name" property in "Result Message".
-
Add a Placeholder to the Multi Message Unit: right click on the Multi Message Unit → Add → Placeholder. Change the Name property in "employeeName".
-
Add a Placeholder to the Multi Message Unit: right click on the Multi Message Unit → Add → Placeholder. Change the Name property in "employeeSurname".
-
Set the Message Text property of the Multi Message Unit. For example: “The employee $$employeeName$$ $$employeeSurname$$ has been created.”
-
Draw an OK link between the "Create Employee" Create Unit and the "Result Message" Multi Message Unit: select the Link button from the palette and click on the "Create Employee" Create Unit (the Source of the OK Link) and then on the "Result Message" Multi Message 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 "name" and "surname" Attributes of the Create Unit with the "employeeName" and "employeeSurname" Placeholders of the Multi Message 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 Multi Message Unit
|
The message text of the Multi Message Unit
|
The Parameters Coupling window of the input link to the Multi Message Unit
|
|
The generated Web application