Skip to main content link. Accesskey S

The useful resource for IBM Lotus Domino XPages development

Submit Search

Available in the Appstore!All the content of xpageswiki.com for iPhone or iPad for offline access.

Home > Server JavaScript > Work with scoped variables

Work with scoped variables

ShowTable of Contents

Place data into a variable


sessionScope.put("key", "some string value");
var a = new Array();
a.push("value1");
a.push("value2");
sessionScope.put("anotherkey", a);

Get data


var v = sessionscope.get("key");

Scope types

applicationScope


Are visible for all users of one application. Expires some time after the last user used an applicationScope variable.
That means applicationScope variables are NOT persistent forever. But they can be used for caching stuff for all users.

sessionScope


Is valid through the session of the current user. A user session expires after some time of inactivity. Uses don't have access to the sessionScope variables of other users.

requestScope


Is valid through one request of the current user. That includes refreshing of a page.

viewScope


Is visible for views on the current page only. Useful for transporting a search query to a view.
Created by Anonymous on Aug 18, 2009 1:22:58 PM

Hi Julian,

do sessionScope vars also work across databases (during the same session of course)?


Created by Julian Buss on Aug 18, 2009 1:44:10 PM

yes


Created by Anonymous on Aug 24, 2009 2:03:23 PM

...but I do not receive data, when retrieving them from within another database...


Created by Anonymous on Dec 18, 2010 9:58:53 PM

Bug or feature? sessionScope is local for every NSF. Also applicationScope has key based on NSF path, so differrent URLs to the same app lead to different applicationScope storage. (tested on 8.5.2)


Created by Julian Buss on Dec 29, 2010 11:51:25 AM

feature! (from my point of view :-) ).

ApplicationScope means by it's name that it's per application. And since sessionScope is lower than applicationScope, it has to be per application, too.


Created by Daniel on Jul 13, 2011 12:43:15 PM

Can you explane me the difference from ViewScope and RequestScope? ViewScope exist only when I have Views Domino?


Created by Erin Woods on Jul 20, 2011 10:10:40 AM

ViewScope is as long as the focus is on the Xpage (the xp:view)

RequestScope is as long as an action (in which the RequestScope is set) takes place, soon as you click enter a tab or your code continues with something else, it is lost.


Add Comment

Name:
Comments:
Use  searchlotus.com  for news in the Web related to Lotus Notes and Domino,
and to search those sites.
Check  youatnotes.com  for great Lotus Notes, Domino and XPages software.
Did this information help you?
Please honor our efforts and flattr this!