Creating custom JavaScript library files

This topic shows you how to include your own JavaScriptâ„¢ libraries in a WebFacing application. Creating your own JavaScript libraries is sometimes necessary when customizing a WebFacing application.

In order for your JavaScript to be published as part of your WebFacing application, it needs to be created in the usr directory. To locate the usr directory, when viewing your WebFacing project switch to the Navigator view, expand your project and expand the folders WebContent > webfacing > ClientScript > usr. Place the file containing your JavaScript library (.js file) in the usr directory. Files contained in this directory will be referenced as include files in the pages sent to the browser by your WebFacing application.

The list of files contained in the usr directory is determined once when the WebFacing application is started. This means that adding or removing files in the directory after the WebFacing application has started will not change the list of files included on each page. Additionally for two or more files there is no fixed order applied to the generated includes.

You can test that your JavaScript library is being included by implementing the function init_usr(). A WebFacing application will make a call to init_usr() after it has completed its load-time processing. To use this call, add an init_usr() function to your JavaScript library file. For example, if you add the following lines to your .js file, an alert will be displayed when the WebFacing application is accessed.
function init_usr()
{
	alert("init_usr() called");
}

Feedback