我正在关注Worklight store fronts 的 WebSphere Commerce 指南,以使用 IBM Worklight 5.0.5 来使用混合应用程序。
应用程序成功启动,但是在应用程序中为店面设置连接详细信息并保存它们之后 - 店面(位于 WebSphere Commerce 服务器上的另一个 Worklight Hybrid 应用程序)未正确初始化。
我收到以下错误消息,而不是正确加载:
Uncaught TypeError: Cannot call method 'init' of undefined at 192.168.16.96/wcsstore/Aurora/mobile20/WorklightHybrid/android/js/initOptionsApp.js:64
HTML 文件代码:
<body id="content" class="bg_splash" style="display: none;">
<!-- application UI goes here -->
<div class="wrapper">
<div id="splashscreen" class="splash_logo_container splash_logo_position splash_logo"></div>
<div id="pagePort" class="hidden"></div>
</div>
<script src="js/version.js"></script>
<script src="js/messages.js"></script>
<script src="js/messages_en_US.js"></script>
<script src="js/messages_fr_FR.js"></script>
<script src="js/messages_de_DE.js"></script>
<script src="js/messages_it_IT.js"></script>
<script src="js/messages_es_ES.js"></script>
<script src="js/messages_pt_BR.js"></script>
<script src="js/messages_zh_CN.js"></script>
<script src="js/messages_zh_TW.js"></script>
<script src="js/messages_ko_KR.js"></script>
<script src="js/messages_ja_JP.js"></script>
<script src="js/messages_ko_KR.js"></script>
<script src="js/messages_ru_RU.js"></script>
<script src="js/messages_ro_RO.js"></script>
<script src="js/messages_pl_PL.js"></script>
<script src="js/WCLocalStorage.js"></script>
<script src="js/WCHybrid.js"></script>
<script src="js/initOptions.js"></script>
</body>
initOptions.js
//Worklight Client initialization parameter array
var wlInitOptions = {
//Application should not attempt to connect to Worklight Server on application start up
connectOnStartup : false,
//Should application produce logs
enableLogger : true,
//Should direct updates prompt the user or occur silently
updateSilently: false
};
var initOptionsApp = (function() {
return {
/**
* Called when Cordova runtime has initialized
*/
onDeviceReady: function() {
var METHODNAME = "initOptionsApp.onDeviceReady";
if (wlInitOptions.enableLogger) {
WL.Logger.debug(METHODNAME, "ENTRY");
}
//bind the hardware back button event listener
document.addEventListener("backbutton", WCHybridApp.onBackKeyDown, false);
if (wlInitOptions.enableLogger) {
WL.Logger.debug(METHODNAME, "EXIT");
}
}
};
})();
/**
* Bind the Worklight Client initialization call to the page load event
*/
if (window.addEventListener) {
window.addEventListener('load', function() { WL.Client.init(wlInitOptions); }, false);
window.addEventListener('unload', function() { WCHybridApp.updateHistory(); }, false);
} else if (window.attachEvent) {
window.attachEvent('onload', function() { WL.Client.init(wlInitOptions); });
}
/**
* Bind events to the Cordova deviceready event
*/
if (document.addEventListener) {
document.addEventListener("deviceready", initOptionsApp.onDeviceReady, false);
}
编辑:升级到 Worklight 5.0.6.1 后,以下问题已修复
当我在模拟器上加载我的应用程序时,它会提示意外的三个不同的对话框,如下图所示。
这里有更多例子: