This article is not up to date and it has been substitute with new up to date content.

Please look the new up to date content.

Context Parameters

by Michela Frigerio
5,960 views Published on Oct 24, 2011
Applies to: All versions
Table of contents

Introduction

Context Parameters are variables stored the application session and are particularly useful when there is the need to share a parameter in several points in the application. Thanks to the fact that Context Parameters are accessible from everywhere in the Web Model, there isn't the need to pass the value we want to share on every link. The only thing we need is to store the value in a Context Parameter and then read it everywhere. Context Parameters are defined on the Project node. Each Context Parameter has a name and a datatype.

Context Parameters datatypes

The datatypes allowed for Context Parameters are all the IFML types plus the "entity" type.

Entity type

Setting a Context Parameter with the "entity" type means that the Context Parameter identifies a particular instance of an Entity in the Data Model. When using the "entity" type, it's necessary to specify the Entity to which the Context Parameter is related to. The Context Parameter will contain the primary key values of the chosen entity instance.

As an example, the UserCtxParam has the type "entity" and is referred to the entity "User".

 

Default Context Parameters

Every WebRatio application has four Context Parameter by default. These Context Parameters are:

  • UserCtxParam: it has the "entity" type referred to the "User" entity and it identifies the currently logged user.
  • GroupCtxParam: has the "entity" type referred to the "Group" entity  and it identifies the Default Group of the currently logged user.
  • CountryISOCtxParam: it has the "string" type and it contains the ISO code of the country currently used by the user to navigate the Web application.
  • LanguageISOCtxParam: it has the "string" type and it contains the ISO code of the language currently used by the user to navigate the Web application.

These four context parameters are automatically managed and set by the WebRatio runtime framework and can be changed by the user in the running application.

Custom Context Parameters

Besides the default Context Parameters there's the possibility to define custom Context Parameters. To add a Context Parameter just right-click on the Project node and choose "Add Context Parameter" menu item.

 

 

 

 

 

 

 

 

As an example we will add the "Product" Context Parameter, that contains the key of a Product instance.


 

Get, Set, Reset Unit

Context Parameters are managed with the Get Unit, the Set Unit and the Reset Unit.

Get Unit

Get Units are used to retrieve values from Context Parameters. The Get Unit is both a Content and an Operation unit, then it can be placed inside or outside pages. Since the Get Unit represents only a reading of a Context Parameter, when placed outside pages, it doesn't need to be activated with a normal or OK/KO Link, just use a transport link to pass the value.

 

 

Set Unit

Set units are used to store values into Context Parameters. The Set Unit is an Operation unit. The Set Unit, due to it's particular function, can't be source of an OK or KO Links, it can be activated by a Link, but not by OK or KO Links.

 

 

Reset Unit

The Reset Unit behaves like a Set Unit, beside it allows to clear session parameters values. The Reset Unit is a standard Operation Unit, activated by Links and source of OK or KO Links.

 

 

 

Example

Suppose that, in the Acme application, we want to show in every page the details of the last product chosen by the user. Using the Context Parameters, we can simply add a Set Unit that writes the chosen product in a new Context Parameter "Product" of type entity associated to the Product entity (as in the example shown above). Then we can add a Data Unit that shows the data of a product in the Master Page, with a Get Unit that passes the value contained in the "Product" Context Parameter (the oid of the Product Entity) to the Key Condition of the Data Unit.

Note the particular way in which the Set Unit is used in the model. In this way everytime we access the Product Page, a new value in the "Product" Context Parameter is set. This is the only pattern in which a transport link can activate an operation unit. In this way, once the user chooses a product, accessing to the Product Page, the data of the "Last Chosen Product" are shown in all the other pages of the application.

 
 

This article is not up to date and it has been substitute with new up to date content.

Please look the new up to date content.