0

After adding following object in messages.js (located at myProject/apps/myApp/common):

WL.ClientMessages = {
  wlSettings : "myApp settings"
};

Although it successfully changed from "Worklight Settings" to "myApp settings" in Android's OptionsMenu, when I look in Logcat it shows the following error:

Uncaught ReferenceError: WL is not defined at file:///data/data/com.test/files/www/default/js/messages.js:10

Also, if I trigger a Direct Update by changing a web resource, it fails with the following error:

tag: test(my app's name)

[http://192.168.1.5:10080/test/apps/services/api/test/android/composite] exception. TypeError: Cannot call method 'replace' of undefined

tag:CordovaLog

Uncaught TypeError: Cannot call method 'replace' of undefined

tag: Web Console

Uncaught TypeError: Cannot call method 'replace' of undefined at file:///data/data/com.test/files/www/default/wlclient/js/worklight.js:1763

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
HoangNguyen
  • 183
  • 2
  • 9

1 Answers1

1

This is because of the way I previously explained my answer to this question: IBM Worklight - How to change the default "Worklight Settings" string?

I have corrected it.

This happens now because messages.js is not in the scope of the WL namespace.
By doing so it will override the whole ClientMessages object, leaving you with only one property - wlSettings. This will cause various pieces of functionality to fail, e.g. direct update failure you're experiencing is caused by the fact that WL framework cannot retrieve the required message string.

Move the object from messages.js to yourApp.js, above wlCommonInit(), and update it like this:

/* myApp.js 
...
...
/*

WL.ClientMessages.wlSettings = "myApp Settings";

function wlCommonInit() {
    ...
    ...
}
Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89