Worklight - getUserPref doesn't persist/load back?

我怕爱的太早我们不能终老 提交于 2019-12-25 03:15:56

问题


I'm trying to persist some data for the user in this WL app using:

WL.Client.setUserPref('foo', 'bar');

and getting it back by using

WL.Client.getUserPref('key');

My target environment is Windows 8.1 with the latest Worklight Studio (6.2.0.01-20141015).

With a user logged in, I have tested this in:

  • Preview Mode
    • Logged a user in
    • Set a user pref
    • Logged out
    • Closed window/tab
    • Opened, logged in again
    • Get back user pref (null)

Using the developer console in Chrome. I can see that there was a call out to save the preference when invoked, and confirmed that it had been set by calling getUserPref.

I've performed much the same test with Visual Studio 2013 by previewing the app and running the commands from the JS Console with the same results.

Is there something I'm missing here?


回答1:


I found that calling the connect after authenticating and before getting the preferences, i.e.:

WL.Cient.connect({onSuccess:successFunction, onFailure:failureFunction});
var myPref = WL.Client.getUserPref("myPref");

This should do the trick.



来源:https://stackoverflow.com/questions/26600974/worklight-getuserpref-doesnt-persist-load-back

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!