What does the getView () function of SAPUI5 do?

1

Good afternoon, I am in full development of an application using SAPUI5, I have serious doubts with this piece of code and I would like to understand what each function does, what is really being done.

this happens inside the "Controller" of a "View" here I leave the view:

And here the Controller:

What I would like to understand is this piece of code:

var ModelDriver = new JSONModel();
            this.getView().setModel(ModelDriver, "infodriver");
            ModelDriver = this.getView().getModel("infodriver");
            ModelDriver.setData({
                //DriverId: "",
                DriverImage: "http://www.buscandolalibertad.com/ext/rockettheme/rokbb/noavatar.jpg"
                //DriverName: "",
                //DriverLastName: ""
            });

Thanks in advance. Greetings

    
asked by Deivbid 01.11.2017 в 15:42
source

1 answer

0

I will explain it to you as I understand it this.getView () is used to access as in view of that controller that calls it later to access one of the controls of that view you do it by byId (), in fact from I think that from version 1.30 or 1.44 I read that you no longer need the getView () but you can do it directly so var = this.byId ('id_element')

You can also access but have not tried an element from another view that is not common, using sap.ui.getCore (). byId (...)

As for the other part of your question what you are doing is creating a model and assigning it to an element and then sending it the data of that model

You create a model var ModelDriver = new JSONModel ();

At that view you assign a model to say so, the other part I'm not sure, the "infodriver" because I do it a little different but it's the same             this.getView (). setModel (ModelDriver, "infodriver");

I do not understand much this line since you are obtaining the model of sight             ModelDriver = this.getView (). GetModel ("infodriver");

you send the data to the model so that you can use the model with data in the view in the part of the image that you indicate {infodriver> / DriverImage}             ModelDriver.setData ({                 DriverImage: " link "

Well already at this point you will surely know more than me that I have been barely a month in this world of ui5

    
answered by 05.03.2018 в 21:17