0
votes

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
This looks less related to the reload and more related to that path there... can you expend more about the structure of your application (multipages?)?Idan Adar
Also explain more about your logout function; surely it doesn't only do a reload...Idan Adar
Thanks Idan for the reply, in logout function we are clearing the localstorage and redirecting the user to main page of the application as shown below. The issue occurs when the user navigates to a page other than the home page and clicks on the logout button 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%'); };Shireesh
Can you try a reload outside of the logout function, does it work correctly? In other words: try to recreate the issue in small testcase app that you can share with us.Idan Adar
how can i share the test case app, where can i upload?Shireesh

2 Answers

0
votes

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.

0
votes

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