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 developersare 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 FW Canvas framework files, the tag name to be used is “CT_READY”.
...
Code Block |
---|
|
<?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> |
...
Code Block |
---|
|
<?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> |
...
Single: To load files mentioned in a single tag.
Code Block |
---|
|
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:
Code Block |
---|
|
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.
Code Block |
---|
|
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:
Code Block |
---|
|
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”);
});
}); |
...