IBM Worklight 6.0 - WL.Client.reloadApp() not work

2019-03-04 14:15发布

We are using Worklight 6.0.0 enterprise edition and currently building hybrid apps for android, BB, Windows Phone 8 and iOS.

We are currently getting the below error when invoking WL.Client.reloadApp() when clicking on a logout button. This works fine all OSs except for WP8.

CordovaBrowser_NavigationFailed :: ///www/default/www/default/pages/www/default/pages/www/default/pages/www/default/pages/myaccount.html ERROR: Exception in InvokeScriptCallback :: An unknown error has occurred. Error: 80020006. ERROR: Exception in InvokeScriptCallback :: An unknown error has occurred. Error: 80020006.

This is our logout function:

logout() {
    window.localStorage.clear();
    $.mobile.changePage("../MainPage.html");
    $('#username').val('');
    $('#password').val('');
    $("#Footer").show();
    $("#ui_logoutlst").hide();
    $("#homeBt_menu").hide();
    $('ul#QuickLinks li').width('50%');
};

2条回答
Bombasti
2楼-- · 2019-03-04 14:44

Looking at the edited comments and question, the problem could be at the path used.

Take a look at the multi-page sample project provided in the IBM Worklight Getting Started webpage. It contains special handling for WP8 which you may need to apply to your logout function as well.

Building a multi-page application training module
Multi-page sample project

Note how the path is handled specifically for Windows Phone 8.
common\main.js:

var path = "";

function wlCommonInit(){
    // Special case for Windows Phone 8 only.
    if (WL.Client.getEnvironment() == WL.Environment.WINDOWS_PHONE_8) {
        path = "/www/default/";
    }
   ...
   ...
}

You need to now do one of two things:

  • account for the path for WP8
  • alter jQuery Mobile's JS if you use that
查看更多
对你真心纯属浪费
3楼-- · 2019-03-04 14:48

Updated April 8th, 2014

I have used the sample project you've provided in my previous answer.
Here's an updated version: WindowsTestApp

What I've done:

  1. Removed use of the path variable in wlCommonInit().

  2. Added the changeHash: false option to $.mobile.changePage().

    For example: $.mobile.changePage("Pages/MyAccount.html", { changeHash: false });

  3. In WindowTestApp.html

    Removed this line from the HEAD element:

    <script>window.$ = window.jQuery = WLJQ;</script>

  4. In js\jquery-1.10.2.js:

    Find

    xhr.open(s.type, s.url, s.async);

    Change to

    s.url = s.url.replace("x-wmapp0:///", "");
    xhr.open(s.type, s.url, s.async);


Step 3 is correct use of changePage in case of using WL.Client.reloadApp().

Step 4 seems to be a bug in jQuery/jQuery Mobile specific to handling to file location in Windows Phone.

查看更多
登录 后发表回答