@openui5/sap.ui.core
Version:
OpenUI5 Core Library sap.ui.core
58 lines (52 loc) • 1.83 kB
JavaScript
/*!
* OpenUI5
* (c) Copyright 2026 SAP SE or an SAP affiliate company.
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
*/
/*eslint-disable max-len */
// Provides the JSON model implementation of a property binding
sap.ui.define([
'sap/ui/model/ChangeReason',
'sap/ui/model/ClientPropertyBinding',
"sap/base/util/deepEqual"
],
function(ChangeReason, ClientPropertyBinding, deepEqual) {
"use strict";
/**
*
* @class
* Property binding implementation for Messages
*
* @param {sap.ui.model.message.MessageModel} oModel
* @param {string} sPath
* @param {sap.ui.model.Context} oContext
* @param {object} [mParameters]
* @alias sap.ui.model.message.MessagePropertyBinding
* @extends sap.ui.model.ClientPropertyBinding
*/
var MessagePropertyBinding = ClientPropertyBinding.extend("sap.ui.model.message.MessagePropertyBinding");
/*
* @see sap.ui.model.PropertyBinding.prototype.setValue
*/
MessagePropertyBinding.prototype.setValue = function(oValue){
if (!deepEqual(this.oValue, oValue)) {
// the binding value will be updated by the model. The model calls checkupdate on all bindings after updating its value.
this.oModel.setProperty(this.sPath, oValue, this.oContext);
}
};
/**
* Check whether this Binding would provide new values and in case it changed,
* inform interested parties about this.
*
* @param {boolean} [bForceupdate]
* Whether interested parties should be informed regardless of the bindings state
*/
MessagePropertyBinding.prototype.checkUpdate = function(bForceupdate){
var oValue = this._getValue();
if (!deepEqual(oValue, this.oValue) || bForceupdate) {// optimize for not firing the events when unneeded
this.oValue = oValue;
this._fireChange({reason: ChangeReason.Change});
}
};
return MessagePropertyBinding;
});