Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TestPanel.controller.js
Go to the documentation of this file.
1sap.ui.define([ 'rootui5/panel/Controller', 'sap/ui/model/json/JSONModel', 'sap/m/MessageToast' ],
2 function(GuiPanelController, JSONModel, MessageToast) {
3 "use strict";
4
5 return GuiPanelController.extend("localapp.controller.TestPanel", {
6
7 // function called from rootui5.panel.Controller
8 onPanelInit : function() { this.setPanelTitle("TestPanel"); },
9
10 // function called from rootui5.panel.Controller
11 onPanelExit : function() {},
12
13 onPanelReceive : function(msg, offset) {
14 if (typeof msg != "string") {
15 // binary data transfer not used in this example
16 var arr = new Float32Array(msg, offset);
17 return;
18 }
19
20 if (msg.indexOf("MODEL:") == 0) {
21 var data = JSON.parse(msg.substr(6));
22 if (data)
23 this.getView().setModel(new JSONModel(data));
24 } else {
25 MessageToast.show("Receive msg: " + msg.substr(0, 30));
26 }
27 },
28
29 handleButtonPress : function() { MessageToast.show("Press sample button"); },
30
31 // just send model as is to the server back
32 handleSendPress : function() { this.panelSend("MODEL:" + this.getView().getModel().getJSON()); },
33
34 handleRefreshPress : function() { this.panelSend("REFRESH"); }
35 });
36 });