Skip to Content
0
May 08, 2018 at 05:29 AM

why array is shared in extended mvc controller?

61 Views

Hi Expert,

I have below code to define a new MVC controller. and we found the _legMap is shared between instances but other values are not.


We tried to create several xml view with this controller, other values are default like null or "" but the "_legMap" is not. It contains all value we added in previous creation.


Any idea why it happened? BTW, I use UI5 version "1.52.6"

sap.ui.define(['jquery.sap.global', "sap/ui/core/mvc/Controller",
	"sap/m/MessageBox",
], function (jQuery, oController, MessageBox) {
	"use strict";

	var mycontroller=
		oController.extend("mycontroller", {
			_container: null,
			_customerName: "",
			_fromId: "",
			_lastSender: "",
			_lastSentTime: "",
			_created: "",
			_messages: null,
			_contactId: null,
			_legMap: [],
			_oCcAPI: null,
			_i18nModel: null,
			_displayModel: null,
			_iUnresolvedLegCounter: 0,


			onInit: function () {
				// read data from API; Show Busy?
				this._container = this.byId("ContextContainer");
				this._displayModel = new sap.ui.model.json.JSONModel({
					"legalHold": 0, 
					"legalHoldBtnVisible": false
				});