gpt4 book ai didi

javascript - 从 JSP 调用 EXTJS 方法时未捕获的类型错误和 Uncaught ReferenceError

转载 作者:行者123 更新时间:2023-11-28 01:45:59 24 4
gpt4 key购买 nike

XTJS 代码的一小部分:

Ext.define('MyApp.Alarms.Exporter', {
namespace : undefined,
exportMax : undefined,
pdfLink : undefined,
excelLink : undefined,
totalAlarms : 0,
//UI
windowDialog : undefined,

constructor : function(namespace, pdfLink, excelLink,
exportMax) {
this.namespace = namespace;
this.pdfLink = pdfLink;
this.excelLink = excelLink;
this.exportMax = exportMax;
},

setTotalAlarms : function(value) {
this.totalAlarms = value;
},

doExport : function(format) {
var url = '';
var totalAlarms = this.totalAlarms;

if (totalAlarms > this.exportMax) {
if (this.exportMax != 0) {
totalAlarms = this.exportMax;
}
}

if (totalAlarms > 0) {
if (format == 'pdf') {
url = this.pdfLink;
} else {
url = this.excelLink
}

this.show(url, totalAlarms);
} else {
Ext.Msg.show({
title : 'Export Alarms',
msg : 'There are no alarms to export',
buttons : Ext.Msg.OK,
icon : Ext.Msg.INFO
});
}
}

});

JSP 代码:

使用随机命名空间创建对象AlarmsExporter

    if (typeof <%= table.getNamespace() %>AlarmsExporter == 'undefined') {
<%= table.getNamespace() %>AlarmsExporter = Ext.create('MyApp.Alarms.Exporter', '<%=table.getNamespace()%>', '<%=Util.encodeUrl(request, response, table.getPdfLink())%>', '<%=Util.encodeUrl(request, response, table.getExcelLink())%>', '<%= Util.getNumAlarmsExport()%>');
}

调用ext方法doExport()

            <a href="javascript:<%= table.getNamespace() %>AlarmsExporter.doExport('xls');">
<img src="<%= xlsIcon %>" alt="Save as Excel Spreadsheet">
</a>
<a href="javascript:<%= table.getNamespace() %>AlarmsExporter.doExport('pdf');">
<img src="<%= pdfIcon %>" alt="Save as PDF"/>
</a>

现在,当我单击这些链接时,我收到错误:

Uncaught TypeError: object is not a function 

Uncaught ReferenceError: _mo_navigation_WAR_ManagedObjectsPortlets_INSTANCE_Bk8L_AlarmsExporter is not defined 

最佳答案

因为包含 extjs 代码的 .js 文件丢失或无法从 JSP 访问。检查 JSP 中是否包含 .js 或路径是否正确。

我相信这应该可以解决您的问题。

关于javascript - 从 JSP 调用 EXTJS 方法时未捕获的类型错误和 Uncaught ReferenceError ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20322286/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com