applicationScope (JavaScript)

Allows you to share values across pages for the duration of an application.

This global object is based on the Java class com.sun.faces.context.ApplicationMap which includes the following methods:
put(p0:java.lang.Object, p1:java.lang.Object) : java.lang.Object
get(p0:java.lang.Object) : java.lang.Object
For example, a button on a page might contain the following code for the onClick event:
applicationScope.put("hello", "Hello application");
A label on a second page might have the following formula:
applicationScope.get("hello");

If a user clicks the button on the first page then opens the second page, Hello application appears as the label.

The value persists as long as the application exists. For example, if you click the button on the first page, close the application, reopen the application, and go to the second page, the value will still be there.

The name of the value and the value can be any object. For example, you can use the following combinations:
applicationScope.put(1, "Hello application");
applicationScope.get(1);

applicationScope.put("n", 99);
applicationScope.get("n");
You can also put and get values as you would properties. For example, you can assign a value on the first page as follows:
applicationScope.hello = "Hello application";
On the second page, you can reference the value as follows:
applicationScope.hello;
You can bind a applicationScope variable to a control. For Data source, select EL Scopes. For Data binding, select applicationScope. You will see #{applicationScope.}. Type the name of the variable after the period, for example:
#{applicationScope.hello}