Recent articles by this author

Question:

I have an XPage viewpanel which shows documents from a view. A column is configured to show values as links. However, the links by default open the document in another XPage. How can I change the default link generated for each entry in the view panel to open the document ...

Question:

Are global variables in server-side JavaScript libraries shared across the board regardless of the user/session ?

Answer:

Yes, global variables defined in server-side JavaScript libraries are initially indeed globally shared across sessions.
However, they are not guaranteed to be available for the life-cycle of the application and might get discarded by the run-time at any time.
Therefore, it is not recommended to rely on this.

To understand the reasons for this, let's look at how server-side script libraries work:
A script library is loaded once a page requests it. It is compiled, the statements outside a function body are executed, and a list of global variables is maintained.
For example, each function defined in the library is a global variable of type "function", as well as the constants you defined.
How long this data is kept in memory is undefined. If the operating system is reclaiming memory, then this data is discarded, and will be reconstructed when a page requests it again. After it has been discarded and reconstructed, the original value of the global variables are lost.
Note that data cannot be discarded while they are actively in use by a page, so it is safe during the request phase for a page. The recommended way to reliably store and share global variables across user sessions is to use the applicationScope.