Skip to Content

"oModel.oData" warning

I am fixing the warnings of some code. There is a warning in the code below:

onDeleteListItem: function(oEvent) {
			this.getView().byId("tileList");
			var sPath = oEvent.getParameters("list").listItem.getBindingContext().sPath;
			var iLength = sPath.length;
			var iIndex = sPath.slice(iLength - 1);
			var oModel = this.getView().getModel();
			var oData = oModel.oData;
			oData.TileCollection.splice(iIndex, 1);
			oModel.setData(oData);
		}

In this line

var oData = oModel.oData;

there is a warning: Property oData is a private member of sap.ui.model.odata.v2.ODataModel. (sap-no-ui5-prop-warning).

How can I fix it?

Thank you!

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Feb 18 at 08:33 PM

    Hi Jerry,

    You are directly accessing oData property which is private property..

    Assuming that this is a JSON model, you need to use oModel.getData() (similar to oModel.setData), which will return you the data

    You can check the API reference for more details

    BR

    Mahesh

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 18 at 10:47 PM

    In case of OData for other readers, this might help: https://stackoverflow.com/a/54554635/

    Generally, UI5 provides almost always an appropriate API for every common case for which the API reference should be checked.

    Accessing non-public fields as an application developer is considered highly risky and harmful for upward compatibility.

    Add comment
    10|10000 characters needed characters exceeded