Difference between revisions of "Variables in QPR UI"

From Mea Wiki
Jump to navigation Jump to search
Line 11: Line 11:
 
* '''Inherited''': Inherited variables get their value from the upper level if a variable having the same name exists in the upper level. If it doesn't exist in the upper level, the variable gets a value that is set in its definition (in the Context tab). If the upper level variable starts to exist after the initialization, the upper level value replaces the defined value.
 
* '''Inherited''': Inherited variables get their value from the upper level if a variable having the same name exists in the upper level. If it doesn't exist in the upper level, the variable gets a value that is set in its definition (in the Context tab). If the upper level variable starts to exist after the initialization, the upper level value replaces the defined value.
  
When setting variable values via actions (for example in a [[Data_Grid_Properties#Data_Grid_Click_and_Popup_Menu_Events|data grid]]) or in HTML presentation object, you can either set the local variable value or set a value to the session level (called '''Global'''). When setting the local value, always the nearest defined local or optional variable value is set. For example, when setting a value from a data grid, the data grid presentation object is the nearest one, the panel is the next and the view is after the panel. If there is no local or optional variable defined at all, the value is set to the session level.
+
When setting variable values in presentation objects, you can either set the Local/Optional variable value or set a value to the session level (called '''Global'''). In a [[Data_Grid_Properties#Data_Grid_Click_and_Popup_Menu_Events|data grid actions]] the setting is called '''scope''', and in [[HTML_Properties#Setting_Context_Variables_in_JavaScript|HTML presentation object functions]], it's done using a parameter named presentation object runtime id. When setting the Local/Optional variable value, always the nearest defined Local/Optional variable value is set. For example, when setting a value from a data grid, the data grid presentation object is the nearest level, the panel is the next and the view level is after the panel. If there is no Local/Optional variable defined at all, the value is set to the session level.
  
 
== Context Variables Usage Example ==
 
== Context Variables Usage Example ==

Revision as of 07:21, 7 June 2018

Context variables in QPR UI are for storing session time information and communicating between different user interface elements, such as views, panels and presentation objects.

Context Variable Behaviors

Each UI element (i.e. view, panel, presentation object) has a set of effective values for variables (effective context), which consist of the values of all variables visible at that level (the variables may have been defined at that level or any upper levels). Variables can be defined in the following levels: Session, View, Panel and Presentation Object. Variables in the session level cannot be defined, but they start to exist there when they are set for the first time.

The variables in QPR UI have the following types of behaviors which determine how the variables work:

  • Local: Local variables are visible in the level where the variable is defined and also in all its sub levels. When initialized, the local variable gets a value that is set in its definition (in the Context tab). Note that when setting a local variable value, the value is changed for the nearest local variable.
  • Optional: Optional variables work like local variables, except the optional variable gets its initial value from the upper level when the level is initialized. For example, optional variables in view level get their values from the session level (when a view is opened), and optional variables in the panel level get their values from the view level (when the panel is initialized). If a variable having the same name doesn't exist in the upper level during the initialization, the optional variable will have the value that is set in its definition (in the Context tab). After the optional variable value is initialized, the changes in the upper level variables don't affect the optional variable value.
  • Inherited: Inherited variables get their value from the upper level if a variable having the same name exists in the upper level. If it doesn't exist in the upper level, the variable gets a value that is set in its definition (in the Context tab). If the upper level variable starts to exist after the initialization, the upper level value replaces the defined value.

When setting variable values in presentation objects, you can either set the Local/Optional variable value or set a value to the session level (called Global). In a data grid actions the setting is called scope, and in HTML presentation object functions, it's done using a parameter named presentation object runtime id. When setting the Local/Optional variable value, always the nearest defined Local/Optional variable value is set. For example, when setting a value from a data grid, the data grid presentation object is the nearest level, the panel is the next and the view level is after the panel. If there is no Local/Optional variable defined at all, the value is set to the session level.

Context Variables Usage Example

There is a view with one panel, in which there is one presentation object. The Session context variable values are defined as follows:
800px

In the View Properties, the following context variable values are defined:
800px

In the Panel Properties, the following context variable values are defined:
800px

In the Presentation Object Properties, the following context variable values are defined:
800px

In the Effective View Context, these result into the values shown below. Note the Source column displaying the information where the effective context comes from: 800px

In the Effective Panel Context, these result into the values shown below. Note the Source column displaying the information where the effective context comes from: 800px

In the Effective Presentation Object Context, these result into the values shown below. Note the Source column displaying the information where the effective context comes from: 800px

To put it more concisely, the context variable values (and their behaviors) are as follows:

Context Variable Session View Panel Presentation Object
AccountManager John Smith William Taylor (Local) Susan Chapman (Inherited)
Country Sweden Finland (Local) China (Optional)
ProductGroup Umbrellas (Local)
CustomerGroup Kids

The effective context values are:

Context Variable Session View Panel Presentation Object
AccountManager John Smith William Taylor William Taylor
Country Sweden Sweden Finland Finland
ProductGroup Umbrellas
CustomerGroup Kids Kids Kids

Context Variables and Web Browser History

Any time the session context is modified (like when clicking a Pushbutton or modifying ProcessAnalyzer Presentation Object settings that cause session variables to be modified), a browser history entry is created. The preceding values in the session context can be restored via the browser's Back button. Left-clicking the Back button will restore the previous session context values, whereas right-clicking the Back button will show a list of session context changes to select from. Selecting an entry on the list will restore the session context from that entry.
BrowserHistory.png

Setting Context Variable Values in URL

It's possible to set context variable values in the URL of the QPR UI view. To do this, append "&<variable name>=<variable value>" to the end of the URL. For example: http://localhost:8080/ui/#/dashboard?sys:dashboard=24026&myvariable=myvalue

Defining View Properties and Variables

To define context variables, type in the name of the variable to the text field and click the check mark. After that, you can click the value field and type in the value for your context variable. Context variables starting with "sys:" are system variables which have special purpose in QPR UI - use them only for their intended purpose. The Behavior selection affects the context variable used explained in Context Variable Behaviors. To see what context variable values are used in the view, panel, or presentation object, select the Show effective context check box in the Context tab of the view, panel, or presentation object properties pages.

Variables Usage Example

There is a view with one panel, in which there is one presentation object. The Session variable values are defined as follows:

Variable name Value
AccountManager John Smith
Country Sweden

In the View Properties, the following variable values are defined:

Variable name Value Behavior
AccountManager William Taylor Stored variable
CustomerGroup Kids Local variable

In the Panel Properties, the following variable values are defined:

Variable name Value Behavior
AccountManager Susan Chapman Local variable
Country Finland Local variable

In the Presentation Object Properties, the following variable values are defined:

Variable name Value Behavior
ProductGroup Umbrellas Stored variable

In the Effective View Context, these result into the values shown below. Note the Source column displaying the information where the effective context comes from:

Variable name Value Source Scope
AccountManager William Taylor Scope of the view View
Country Sweden Inherited from session context Session
CustomerGroup Kids Scope of the view View

In the Effective Panel Context, these result into the values shown below. Note the Source column displaying the information where the effective context comes from:

Variable name Value Source Scope
AccountManager Susan Chapman Initialized from the panel's context Panel
Country Finland Initialized from the panel's context Panel
CustomerGroup Kids Inherited from the effective context of the view View

In the Effective Presentation Object Context, these result into the values shown below. Note the Source column displaying the information where the effective context comes from:

Variable name Value Source Scope
AccountManager Susan Chapman Inherited from the effective context of the panel Panel
Country Finland Inherited from the effective context of the panel Panel
ProductGroup Umbrellas Scope of the presentation object Presentation object
CustomerGroup Kids Inherited from the effective context of the view View

To put it more concisely, the context variable values (and their behaviors) are as follows:

Context Variable Session View Panel Presentation Object
AccountManager John Smith William Taylor (Stored variable) Susan Chapman (Local variable)
Country Sweden Finland (Local variable)
ProductGroup Umbrellas (Stored variable)
CustomerGroup Kids (Local variable)

The effective context values are:

Context Variable Session View Panel Presentation Object
AccountManager John Smith William Taylor Susan Chapman Susan Chapman
Country Sweden Sweden Finland Finland
ProductGroup Umbrellas
CustomerGroup Kids Kids Kids

See Also