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