Skip to main content
Version: 11.2

The UdbContext object

note

This article is about the UdbContext object used in the $.udb interface. It is returned by the .context() function and is used by various functions.

The UdbContext object

The UdbContext object represents the entity of a frame context, which is either the entire web application itself (i.e. the root context), or the contents rendered through a Frame Control. It exposes several functions that can be used to control the data contained by this object.

This object is returned by the $.udb.context() function.

A frame context contains several important objects, of which the page stack, data sources and generic host variables are the most important ones. Its functions handle everything regarding page initialization and navigation, data source management for this single context.

A frame context is either created by the application itself (the root context), or by a Frame Control embedded anywhere in the application. Frame contexts can be nested as well (frames contained in frames).

Syntax

The ID of the context object refers to the root context if it has the value '' (empty string). A subframe within the root context is referred to by the name of the frame. In context, names of frames contained in frames are separated from the name of the containing frame by a forward slash:

$.udb.context('MyFrame/SubFrame')
.execute(() => {
if (!$.udb.isCommitted())
return $.udb.commit( { quiet: true });
else
return this;
});

Functionality

The following functions are offered through the UdbContext object. These functions are also available through the $.udb object as well.

Function$.udb equivalentExplanation
.currentEmbeddedPagePath()$.udb.currentEmbeddedPagePath()Returns the full path leading to the embedded page currently being browsed.
.currentEmbeddedPageName()$.udb.currentEmbeddedPageName()Returns the name of the embedded page currently being browsed.
.getEmbeddedPageName()$.udb.getEmbeddedPageName()Returns, on the basis of a page alias, the name of a page embedded in the page being browsed.
.getEmbeddedPagePath()$.udb.getEmbeddedPagePath()Returns, on the basis of a page alias, the full path leading to of a page embedded in the page being browsed.
.mainPageName()$.udb.mainPageName()Returns a string that is the name of the first page in the page stack currently being browsed.
.navSource()$.udb.currentPageNavigationSource()Returns the method used to navigate to the current page.
.pageNum()$.udb.currentPageStackDepth()Returns the number of pages in the page stack currently being browsed.
.navigateTo()$.udb.navigateTo()Navigates to a different page.
.navigateToRelated()$.udb.navigateToRelated()Navigates to a related page.
.navigateToLookup()$.udb.navigateToLookup()Navigates to a lookup page.
.closePage()$.udb.closePage()Closes the page and returns to the previous page on the stack.
.isTransactionChecked()$.udb.isTransactionChecked()Checks for unchecked manipulations, i.e. manipulations that have not been processed by the server by a .checkData() function call.
.isTransactionCommitted()$.udb.isCommitted()Checks for uncommitted manipulations.
.ping()$.udb.ping()Sends a signal to the server to notify that the connection must be kept alive.
.checkData()$.udb.checkData()Checks all data manipulations against the database.
.commit()$.udb.commit()Commits data manipulations (INSERT, UPDATE, DELETE)
.rollback()$.udb.rollback()Rolls back manipulated data.
.genericHostVar()$.udb.genericHostVar()Assigns a value to a generic host variable.
.clearGenericHostVars()$.udb.clearGenericHostVars()Clears all generic host variables.
.executeSQLStatement()$.udb.executeSQLStatement()Executes a SQL statement.
.apply()$.udb.applyCurrentContext()Switches the default context of the function.
.execute()$.udb.executeInContext()Executes the function in this context.

Examples

$.udb.context('ApplicationFrame').checkData({ precommit: true });
$.udb.context('ApplicationFrame').execute(() => {
return $.udb.executeSQLStatement('calculate_some_values', {
hostvars: {
PK: $.udb('Data').rows('current').cols('PK').val()
}
});
});