External JavaScript (screen-level)



Screen-level external JavaScript files are only loaded when a particular application screen is reached by the user. Once the JavaScript code is loaded into memory, it is not unloaded until the session ends.

The JavaScript file to load is specified on the "external javascript" screen-level property. The Visual Designer provides a convenient IFS file browse dialog for this property. The typical IFS directory to store such files is /www/profoundui/htdocs/profoundui/userdata/js.

If it is necessary to load more than one JavaScript file per screen, you can right-click the property and select the option labeled Add Another Exernal JavaScript.

Note that it may not be possible to use the JavaScript code loaded at the screen-level on the "onload" event.  This is because JavaScript code loads asynchronously and may not have finished loading by the time the event has fired.  To resolve this, the JavaScript file may need to be loaded on a previous screen or globally. 

Example:

The following JavaScript code would be saved in a file on the IFS.

function validateNewsletterSetting() { if (getObj("NEWSLETTER").checked && get("EMAIL") == "") { // if newsletter checkbox is checked and email address is blank alert("You selected the checkbox to receive the weekly newsletter. Please provide an email address."); // show message to user getObj("EMAIL").focus(); // focus cursor onto the email field return false; // validation check failed; prevent the screen from submitting by returning false } return true; // validation check passed }

Then, the "external javascript" property should be assigned to the path for this file. Finally, "validateNewsletterSetting()" will be placed on the "onsubmit" screen-level event.