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

问题描述

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

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

并使用



<$ p将其取回$ p> WL.Client.getUserPref( '钥匙');

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



在用户登录后,我已对此进行了测试:




  • 预览模式

    • 用户登录

    • 设置用户首选项

    • 已退出

    • 关闭窗口/标签

    • 已打开,再次登录

    • 获取用户pref(null)




使用Chrome中的开发者控制台。我可以看到在调用时有一个调出来保存首选项,并确认它是通过调用getUserPref设置的。



我执行了大量相同的测试使用Visual Studio 2013,预览应用程序并运行JS控制台中的命令,结果相同。



这里有什么我不知道的吗?

解决方案

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

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

这应该可以解决问题。


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?

解决方案

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.

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

10-29 01:11