Download Manager

Download Manager is a unique feature available in Canvas, which enables the developers to load the JS files on demand, or in other words, the developers can load the file if-and-when it is required. In order to achieve this, the developers are expected to have an entry in a specific tag name** of their choice in the file defined in the bundle mapped for the key CT_WEBUTIL_BUNDLE in the master properties file used by the Configuration Manager. By default, the file used for on-demand loading in CTModelHouse is ondemandjsfiles_lib.xml. The same user configured tags that have been configured by the user with the associated JS files are to be used in the client side to get the JS files on-demand.

**For the files that are supposed to be loaded before the Canvas framework files, the tag name to be used is “CT_READY”.

All the files referenced within the ondemandJSfiles.xml file will be monitored for any type of content modification. The modifications will be rendered on refresh or re-login without the need of restarting the application server.

The structure of the ondemandjsfiles_lib.xml file must be as shown in the following code snippet:

<?xmlversion="1.0"encoding="UTF-8"?>
<JsFiles>
	<filesetid = "<FILESET_ID_TO_BE_USED_ON_THE_CLIENT_SIDE>">
	<fileurl = "<JSFILES_WITH_RELATIVE_PATH_THAT_ARE_NEEDED_TO_BE_DOWNLOADED>" />
	</fileset>
</JsFiles>

A sample ondemandjsfiles_lib.xml must look like as shown in the following code snippet:

<?xmlversion="1.0"encoding="UTF-8"?>
<JsFiles>
<filesetid = "WSPACE_PAYMENTS">
<fileurl = "/javascript/CustomMenu_Retail.js" />
	<fileurl = "/javascript/CustomZolog.js" />
	<fileurl = "/javascript/canvas.listWidget.js" />
</fileset>
<filesetid = "WSPACE_LIQUIDITY">
<fileurl = "/javascript/CustomMenu_Retail.js" />
	<fileurl = "/javascript/CustomZolog.js" />
	<fileurl = "/javascript/canvas.listWidget.js" />
</fileset>
</JsFiles>

The syntax for the CBXDownloadManger to download the JS at the client side is provided in the following code snippet:

Single: To load files mentioned in a single tag.

CBXDOWNLOADMGR.requestScripts(“<FILESET_ID_TO_BE_USED_ON_THE_CLIENT_SIDE>”, 
  function()
  {
	//Call back function should be used once the file is ready 
	//because the download manager works in Async way.
  });

Sample usage of the single tag download manager:

CWMH.registerHandler("CT_CHILD_MENU1", CWMC.EVENT_CLICK, function (config)
  {
	CBXDOWNLOADMGR.requestScripts("WSPACE_CUSTOM",function(){
     //Following lines are executed after retrieving the files.
		CBXFORMCONTAINER.getWindow(“MY_CONTAINER”);
	});	
});

Multi: To load files mentioned in Multiple Tags.

CBXDOWNLOADMGR.requestScripts(cbx.downloadProvider.getMergedArray( 
["<FILESET_ID_TO_BE_USED_ON_THE_CLIENT_SIDE>", 
 "<FILESET_ID_TO_BE_USED_ON_THE_CLIENT_SIDE>"]), function()
   {
	  //Call back function should be used once the file is ready 
	  //because the download manager works in Async way.
});

Sample usage of the multi tags download manager:

CWMH.registerHandler("CT_CHILD_MENU1", CWMC.EVENT_CLICK, function (config)
{
	CBXDOWNLOADMGR.requestScripts(cbx.downloadProvider.getMergedArray( 
		["WSPACE_CUSTOM","WSPACE_CUSTOM_002"]),function(){

		//Following lines are executed after retrieving the files.
		CBXFORMCONTAINER.getWindow(“MY_CONTAINER”);
	});	
});