Let's follow up this discussion at the Neptune Community

(this forum will be kept in read-only mode)
Not Taken

Set Busy indicator for initial load

Dear Neptune Team


Is it possible to set the BusyIndicator for init loading?


Normally you set this before calling getOnline functions...


But in case of initLoad (e.g. InitLoad is set to onlineOnEmptyCache) - how can this be achieved?


I assume this would be a new feature...


Thanks,

Patrick


Great, Patrick!


Do you mind if we keep this in the forum so that other developers can also benefit from it ?  (and I can also copy it as a private ticket from you).


Thanks, cheers,

Julian

hi julio, 


works like a charm. You can move this request away from featrue request and add it as a support ticket of mine?


Thanks,

Patrick

Hi Patrick,


no problem.  Now we are on the same page :)     So, you want to show a busy indicator on the getOnlineoListSpareParts()  that happens if the cache is empty.


You can try the following approach, much simpler:


image


Kind regards,

Julian


Hi Julian


I am very sorry for not being precise so that you misunderstood the problem...


It is about the control oListSpareParts which can contain over 600k entries. It has the following config:

image


With this settings the getCacheoListSpareParts();  is called within an automatically generated function _AppCache_GetCache().


As said loading this list can take long time (10-15sec) to load due to the data volume and thats why I want to set the busy indicator...


Your soultion requires that the script code has to be executed after getCacheXYZ() is defined. Other wise it will not work (old would be a null reference). Since those funtions getCache() or getOnline() are at the end of the script this cannot be the solution, can it?


BR,

Patrick

Thanks, Patrick.


getCache...()  is typically so fast that I have rarely used busy indicators before triggering them.  However, there is a tricky workaround in case you need to execute logic before/after it.


You can include the following in a ScriptCode:


old = getCacheoValueHelpFieldClass; // keep a reference


getCacheoValueHelpFieldClass = function() { // and redefine it


    alert("GetCacheValueHelpFieldClass will be executed"); // <- comment it 

    

    sap.ui.core.BusyIndicator.show(0);

    old.apply(old, arguments);  // call the original function

    sap.ui.core.BusyIndicator.hide();

}



Kind regards,

Julian

Hi Julian


Hope this anwsers your question...

image


BR,

Patrick

Hi Patrick,


What kind of object is oValueHelpFieldClass in your example ? 


Thanks and kind regards,

Julian

Hi Julian


What should I do if it is party of the automatically generated function as shown below?

 

function _AppCache_GetCache(e,t,a,o,n,r,p){window.openDatabase&&"DB"==a?_AppCache_GetCache_DB(e,t,o,n,r,p):_AppCache_GetCache_LS(e,t,o,n,r,p)}function _AppCache_SetCache(e,t,a,o,n,r){window.openDatabase&&"DB"==a?_AppCache_SetCache_DB(e,t,o,n,r):_AppCache_SetCache_LS(e,t,o,n,r)}function _AppCache_GetCache_LS(id,model,online,event,jsonh,encryption){$.sap.require("jquery.sap.storage");var lStorage=$.sap.storage(jQuery.sap.storage.Type.local),modelJSON=lStorage.get(id);if(online&&!modelJSON&&eval(online)(),!modelJSON)return void("function"==typeof eval(event)&&eval(event)());if(encryption){if(0!==modelJSON.indexOf("[")&&0!==modelJSON.indexOf("{")){var decrypted=CryptoJS.AES.decrypt(modelJSON,AppStorage.deviceID);modelJSON=decrypted.toString(CryptoJS.enc.Utf8)}}else if("string"==typeof modelJSON&&0!==modelJSON.indexOf("[")&&0!==modelJSON.indexOf("{"))return;if(jsonh)if("string"==typeof modelJSON)var modelData=JSONH.unpack(JSON.parse(modelJSON));else var modelData=modelJSON;else if("string"==typeof modelJSON)var modelData=JSON.parse(modelJSON);else var modelData=modelJSON;model.setData(modelData),"function"==typeof eval(event)&&eval(event)()}function _AppCache_SetCache_LS(e,t,a,o,n){$.sap.require("jquery.sap.storage");var r=$.sap.storage(jQuery.sap.storage.Type.local);if(a)var p=JSON.stringify(a);else if(o)var p=JSON.stringify(JSONH.pack(t.oData));else var p=t.oData;if(n){var i=CryptoJS.AES.encrypt(p,AppStorage.deviceID);p=i.toString()}r.remove(e),r.put(e,p)}function _AppCache_GetCache_DB(id,model,online,event,jsonh,encryption){try{AppDB.transaction(function(tx){tx.executeSql("SELECT * FROM model WHERE KEY=?",[id],function(tx,results){for(var i=0;i<results.rows.length;i++){var modelJSON=results.rows.item(i).VALUE;if(encryption){if(0!==modelJSON.indexOf("[")&&0!==modelJSON.indexOf("{")){var decrypted=CryptoJS.AES.decrypt(modelJSON,AppStorage.deviceID);modelJSON=decrypted.toString(CryptoJS.enc.Utf8)}}else if("string"==typeof modelJSON&&0!==modelJSON.indexOf("[")&&0!==modelJSON.indexOf("{"))return;if(jsonh)if("string"==typeof modelJSON)var modelData=JSONH.unpack(JSON.parse(modelJSON));else var modelData=modelJSON;else var modelData=JSON.parse(modelJSON);model.setData(modelData),"function"==typeof eval(event)&&eval(event)()}0===results.rows.length&&"function"==typeof eval(event)&&eval(event)(),online&&!model.getData().length&&eval(online)()},null)})}catch(e){return void console.log("Error processing SQL: "+e.message)}}function _AppCache_SetCache_DB(e,t,a,o,n){if(a)var r=JSON.stringify(a);else if(o)var r=JSON.stringify(JSONH.pack(t.oData));else var r=t.getJSON();if(n){var p=CryptoJS.AES.encrypt(r,AppStorage.deviceID);r=p.toString()}try{AppDB.transaction(function(t){t.executeSql("INSERT OR REPLACE INTO model (KEY,VALUE) VALUES (?,?)",[e,r])})}catch(i){return void console.log("Error processing SQL: "+i.message)}}var AppStorage={deviceID:"",Startup:function(){AppStorage.deviceID=localStorage.getItem("AppCacheID"),AppStorage.deviceID||(AppStorage.deviceID=AppStorage.genID(),localStorage.setItem("AppCacheID",AppStorage.deviceID))},genID:function(){var e=(new Date).getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var a=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?a:7&a|8).toString(16)});return t}};AppStorage.Startup(),window.openDatabase&&("undefined"==typeof AppDB&&(AppDB=window.openDatabase("AppCache","1.0","AppCache",5e7)),AppDB.transaction(function(e){e.executeSql("CREATE TABLE IF NOT EXISTS model (KEY VARCHAR PRIMARY KEY, VALUE VARCHAR)")}));
//INIT
oSearchFieldMaster.addStyleClass("customSearchFieldMaster");
oObjectListItemSpareParts.addStyleClass("customListItemSpareParts");
oSBDisplayEdit.addStyleClass("customSegmentedButton");
oSFMaterialBasic.addStyleClass("customSFMaterialBasic");
oImageShown.addStyleClass("customImage");
oSelectImageType.addStyleClass("customSelectImageType");
oTableFollwUp.addStyleClass("customTableRKFU");
oTableRepairKit.addStyleClass("customTableRKFU");
oSFClass.addStyleClass("customSFClass");
getCacheoValueHelpFieldClass();
sap.ui.getCore().attachInit(function() {
setTimeout(function(){
getCacheoListSpareParts();
sap.ui.core.BusyIndicator.hide();
},100);
});

BR,

Patrick

Hi Patrick,


Hope you are doing fine.


The trick is to trigger the load from the Init event, and set the Busy indicator before executing  getOnline...()  / getCache...()


In the case below,  YOUR_OBJECT_NAME  has property  InitLoad = blank


image


Kind regards,

Julian


Login or Signup to post a comment