我正在关注此WebSphere Commerce guide for Worklight store fronts,以使用IBM Worklight 5.0.5使用混合应用程序。
应用程序成功启动,但是在应用程序中设置商店前端的连接详细信息并保存后 - 商店前端(位于WebSphere Commerce服务器上的另一个Worklight Hybrid应用程序)未正确初始化。 / p>
我没有正确加载,而是收到此错误消息:
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
后修复了以下问题当我在模拟器上加载我的应用程序时,会出现意外的三个不同对话框,如下图所示。
更多例子:
答案 0 :(得分:1)
获取这些与Cordova相关的对话框通常意味着您在应用程序中使用的Cordova版本不正确。
我强烈建议您从Eclipse Java EE 4.2.2(Juno SR2)开始,并安装Worklight Developer Edition(Eclipse Marketplace中的v5.0.6.1)。这可能会解决它。
编辑:根据编辑过的问题,它有。
initOptions的重新定位问题目前类似于以下问题:Uncaught ReferenceError: wlInitOptions is not defined