Hey. I need to define a global variable to use anywhere in my application. I declare the global variable baseUrl in app.js . See below app.js
Ext.Loader.setPath({
'Ext': 'touch/src',
'bluebutton': 'app',
});
Ext.application({
name: 'bluebutton',
views: ['Main',
'BlueButton.CouponMain',
'BlueButton.CouponList',
'BlueButton.CouponList2',
'BlueButton.CouponList3',
'BlueButton.TransactionMain',
],
stores : [
'BlueButton.GlobalVariable',
],
models : ['BlueButton.GlobalVariable',
'BlueButton.MemberDetail',
],
controllers: ['Main',
'BlueButton.MemberList',
],
requires: [
'Ext.MessageBox',
],
icon: {
'57': 'resources/icons/Icon.png',
'72': 'resources/icons/Icon~ipad.png',
'114': 'resources/icons/Icon@2x.png',
'144': 'resources/icons/Icon~ipad@2x.png'
},
isIconPrecomposed: true,
startupImage: {
'320x460': 'resources/startup/320x460.jpg',
'640x920': 'resources/startup/640x920.png',
'768x1004': 'resources/startup/768x1004.png',
'748x1024': 'resources/startup/748x1024.png',
'1536x2008': 'resources/startup/1536x2008.png',
'1496x2048': 'resources/startup/1496x2048.png'
},
baseUrl: 'http://192.168.251.108:8080',
launch: function() {
Ext.fly('appLoadingIndicator').destroy();
var LoginLS = Ext.getStore('LoginLS');
LoginLS.load();
var record = LoginLS.getAt(0);
if(record != undefined){
var sessionId = record.get('sessionId');
if (sessionId !=undefined){
var mainView = Ext.getCmp("mainview");
if(!mainView){
mainView = Ext.create('bluebutton.view.Main');
}
Ext.Viewport.setActiveItem(mainView);
}
else
{
var loginView = Ext.getCmp("loginview");
if(!loginView){
loginView = Ext.create('bluebutton.view.Login');
}
Ext.Viewport.setActiveItem(loginView);
}
}
else{
var loginView = Ext.getCmp("loginview");
if(!loginView){
loginView = Ext.create('bluebutton.view.Login');
}
Ext.Viewport.setActiveItem(loginView);
}
},
init: function () {
this.callParent(arguments);
},
onUpdated: function() {
Ext.Msg.confirm(
"Application Update",
"This application has just successfully been updated to the latest version. Reload now?",
function(buttonId) {
if (buttonId === 'yes') {
window.location.reload();
}
}
);
}
});
model.js
Ext.define('bluebutton.model.BlueButton.CouponList', {
extend: 'Ext.data.Model',
config: {
idProperty: 'couponId',
fields: [
{ name: 'couponId' },
{ name: 'couponName' },
{ name: 'description' },
{ name: 'amount' },
{ name: 'couponType' },
{ name: 'merchant_bbID' },
{ name: 'sessionId' },
{ name: 'deviceId' },
],
proxy: {
type: 'rest',
url: bluebutton.app.baseUrl +'/WebCommon/rest/BBWebService/getCouponList',
actionMethods: {
create: 'POST',
read: 'GET',
update: 'PUT',
destroy: 'DELETE'
},
noCache: false,
extraParams: {
sessionId: "1",
merchant_bbID: "merchant1",
},
reader: {
type: 'json',
rootProperty: 'couponList'
},
writer: {
type: 'json',
},
}
}
});
Then I used basedUrl in my model.js. It can work when I use the browser to view. But when I use sencha application assembly testing to compile my applications,
I used the browser to open and it showed me the Uncaught TypeError error message : Unable to read the baseUrl property from undefined . Any idea?