Reputation: 4305
I am creating an application with SAPUI5 (I am new with this library) and I run to the following strange error:
A shared template must be marked with templateShareable:true in the binding info -
Codewise, the cause is to be found in cartelleDisponibili: cartelleObtained
inside the following Promise:
new Promise(
function(resolve, reject) {
cartellaData.results.forEach((cartella, index) => {
oModel.read("/SheetSet", {
filters: [
new sap.ui.model.Filter("ZUSERNAME", sap.ui.model.FilterOperator.EQ, userData.Username),
new sap.ui.model.Filter("ZTYPE", sap.ui.model.FilterOperator.EQ, 'P'),
new sap.ui.model.Filter("ZCARTELLA", sap.ui.model.FilterOperator.EQ, cartella.ZCARTELLA),
],
success: function(sheetData){
var sheetsResults = [];
for(var sheet = 0; sheet < sheetData.results.length; sheet++){
sheetsResults.push({
"Sheet": sheetData.results[sheet].ZSHEET,
"CanWrite": sheetData.results[sheet].ZCANWRITE ? true : false,
});
}
cartelle.push({
"Cartella": cartella.ZCARTELLA,
"CanWrite": cartella.ZCANWRITE ? true : false,
"Sheets": sheetsResults,
});
},
error: function(oEvent) {}
});
});
resolve(cartelle);
}).then(function(cartelleObtained) {
var selectedUser = {
title: `Utente ${userData.Username}`,
editUsername: false,
progNavi: false,
progProd: true,
userMainCredentials: {
userName: userData.Username,
type: "P",
isEnabled: userData.isAbilitato,
isAdmin: userData.isAdmin,
firstName: userData.Nome,
lastName: userData.Cognome,
},
cartelleDisponibili: cartelleObtained,
};
var oJSONModelNewUser = new JSONModel(selectedUser);
_this.getView().setModel(oJSONModelNewUser, "userModel");
if (!_this._dShowUser) {
_this._dShowUser = sap.ui.xmlfragment("cabot.ui.wt.fragment.ShowUser", _this);
_this.getView().addDependent(_this._dShowUser);
}
_this._dShowUser.open();
});
If I pass to cartelleDisponibili
an array of items directly, the error is not thrown. I need to fix this issue also because this is causing some little odd behavior in the UI. How can I solve this issue?
Upvotes: 1
Views: 1665
Reputation: 18044
You must be using an old version of UI5. At least, the error message is not part of the source code anymore since 1.38. The improved error message says a bit more:
During a clone operation, a template was found that neither was marked with 'templateShareable:true' nor 'templateShareable:false'. The framework won't destroy the template. This could cause errors (e.g. duplicate IDs) or memory leaks.
This indicates that, somewhere, you also must be defining an aggregation binding inside a control which is used as a template for another aggregation binding in an upper hierarchy level.
There are two solutions to get rid of the error message (depending on what you want):
templateShareable
(with value true
) explicitly in each aggregation binding info object.templateShareable
(with value false
) in each aggregation binding info object.For more information, take a look at the documentation Lifecycle of Binding Templates and at this blog post by Nabi.
Upvotes: 2