【发布时间】:2023-03-26 06:14:01
【问题描述】:
我已经到了可以部署 extjs 网络应用程序的阶段,并使用 sencha CMD 创建了 jsb 文件,并使用该文件创建了 all-classes.js 和 all-app.js。但是当我尝试运行已部署的版本时它失败了 - 我明白为什么,但我不知道如何修复它。 你看,我的应用的 app.js 文件是这样的;
var SessionData = null;
var Proxy = null;
Ext.Ajax.on('requestexception', function (conn, response) {
if (response.status === 401) {
window.location.href = "../login/index.html";
}
if (response.status === 403) {
var data = Ext.decode(response.responseText);
Ext.MessageBox.alert('Error', data.error);
}
});
....
Ext.Ajax.request({
url :'/LPAA/Servlets/servlet/LPA',
method: 'GET',
params: {
action: App.Actions.UserManagement.VALIDATE,
lpCode: getJsonFromUrl().lpParentCode
},
scope: this,
success: onValidateSession,
failure: function(){
window.location.href = "../login/index.html";
}
});
....
function onValidateSession(response){
SessionData = Ext.decode(response.responseText);
if (SessionData == null || SessionData.userName == null){
window.location.href = "../login/index.html";
return;
}
Proxy = {
type: 'ajax',
url :'/LPAA/Servlets/servlet/LPA',
timeout:120000,
reader: {
root: "array",
type: 'json'
},
writer: {
type: 'json'
}
};
Ext.Loader.setConfig({
enabled: true,
disableCaching: false // this prevents break-points in Chrome's debugger to disappear after reloading the page
});
Ext.application({
requires: [...],
models: [...],
stores: [...],
views: [...],
controllers: [...],
name: 'LPAClient',
launch: function () {
globalApp = this;
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [
{
xtype: 'entitlement'
}
]
});
try {
Ext.create('LPAClient.GeneralUtils');
} catch (ex){}
}
});
}
关键是首先通过服务器验证会话,并且只有当它有效时才会构造应用程序。现在当我运行应用程序时,我在浏览器控制台中遇到的错误是
Uncaught TypeError: Cannot call method 'on' of undefined
哪个来源在代码开头的Ext.Ajax.on('requestexception'...。我可以在网络选项卡中看到 app-all.js 在 Ajax.js 文件之前加载。
如何强制我的应用程序在加载 all-app.js 文件之前加载 Ajax.js 文件?或者换句话说 - 我怎样才能让 app.js 在使用它之前需要“Ext.Ajax”?
干杯, 埃雷兹
【问题讨论】:
-
您是否尝试使用
sencha app build而不是jsb方式? jsb 被推荐用于 ExtJS 3,但不推荐用于 ExtJs 4。 -
我使用了这里解释的“sencha build”命令 - [link]existdissolve.com/2011/08/extjs-4-my-first-build/[link] 你的意思是别的吗?如果是,那是什么?
-
@LorenzMeyer 是对的。如果您已经使用它生成了项目,那么使用 Sencha CMD 部署 extjs4 项目非常容易。您所要做的就是执行命令
sencha app build然后sencha app build production,您就可以部署您的项目了。
标签: ajax extjs extjs4 web-deployment