Worklight-getUserPref不会持久/加载回去吗? [英] Worklight - getUserPref doesn't persist/load back?

查看:43
本文介绍了Worklight-getUserPref不会持久/加载回去吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下方式在此WL应用程序中为用户保留一些数据:

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

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

并通过使用

WL.Client.getUserPref('key');

我的目标环境是带有最新Worklight Studio(6.2.0.01-20141015)的Windows 8.1.

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:

  • 预览模式
    • 登录用户
    • 设置用户偏好
    • 注销
    • 关闭的窗口/标签
    • 已打开,请重新登录
    • 找回用户首选项(空)

    在Chrome中使用开发者控制台.我可以看到有一个调用来保存偏好设置,并通过调用getUserPref确认它已被设置.

    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.

    我通过预览应用程序并从JS控制台运行命令并获得了相同的结果,对Visual Studio 2013进行了相同的测试.

    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?

    推荐答案

    我发现在身份验证之后并在获取首选项之前调用连接,即:

    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");
    

    这应该可以解决问题.

    这篇关于Worklight-getUserPref不会持久/加载回去吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆