How to print Variables and Context Parameters in templates
From Wiki
|
WebRatio allows the user to add Variables to a page in order to define Condition Expression and to use Visibility Conditions in the templates (see Getting started with Visibility Conditions for details). Moreover it's possible to define Context Parameter to store infomation in the sessionContext and make it available for all the JSP session. Sometimes there's the need to use the value of these two elements (Variables and Context Parameters) in the templates. It's possible to use JSTL in order to print these information.
Context Parameters
Suppose you want to print in a page all the default Context Parameters, which are automatically added to every Web Project. These parameters contain information regarding the current Locale and the current User. Let's write a unit template for the NoOpContentUnit like the following:
<table cellspacing="2" cellpadding="1">
<tr>
<td>Current User: ${UserCtxParam}</td>
</tr>
<tr>
<td>Current Group: ${GroupCtxParam}</td>
</tr>
<tr>
<td>Current Language: ${LanguageISOCtxParam}</td>
</tr>
<tr>
<td>Current Country: ${CountryISOCtxParam}</td>
</tr>
</table>
In order to extract the value of a Context Parameter, it's possible to use its identifier or its name. Consider for example a Context Parameter like the one shown in the figure on the right. This is a boolean Context Parameter with "isAdmistrator" as name and with "ctx1" as ID. You can print it using
${isAdministrator}
or
${ctx1}.
The syntax necessary to print it is quite different. The Context Parameter contains only the primary key of the instance object belonging to the associated entity. So, if the primary key of the entity "Product" is the OID attribute, then in order to print it you have to write
${Product.OID}
or
${ctx2.OID}
Variables
Suppose to add to the Home page of the Acme Sample Project a Variable named "LoginFailed". This variable is originally set to the "false" value; then, when the login attempt failes, the variable is set to "true". You can use this variable to create a Condition Expression and to add a Visibility Condition to some page elements.You can also decide to print the variable directly in a template using this syntax
${var1}
or
${LoginFailed}
This syntax does not change when the variable is defined on a entity based unit.
Related articles:
|




