Worklight - 启动时连接失败 [英] Worklight - connection on startup fails

查看:210
本文介绍了Worklight - 启动时连接失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Worklight服务器v6.1我正在尝试开发一个在启动时连接到生产服务器的简单应用程序。要做到这一点:

using Worklight server v6.1 i'm trying to develop a simple app that connects to the production server at startup. To get this i do:


  • in initOptions.js file i set connectOnStartup true

  • wlCommonInit 的方法< my-app> .js 我打电话的文件:

  • in initOptions.js file i set connectOnStartup to true
  • in wlCommonInit method of <my-app>.js file i call :

WL.Client.connect({
onSuccess:已连接,
onFailure:失败
});

其中已连接失败是两次回调两个简单的函数,在listview中加载一些数据。当我在生产或开发环境中使用它时,我会在我的应用程序布局中找到一个位置,说明它正在加载,如下图所示(即使应用程序正确加载了数据):

where connected and failure are two callback to two simple functions that load some data in a listview. When i trie it on a production or development environment i get a spot over my app's layout stating it's loading as you can see in the pic below(even if the application loaded data correctly):

i请注意,在iOS或Android设备上安装并运行后,我没有这种奇怪的行为,但在Windows8设备上我确实有这种行为。

i notice that after installing and running it on an iOS or Android device i don't have this strange behaviour, but on Windows8 devices i do have.

我设置为false connectOnStartup并且只保留对WL.Client.connect的调用。
现在应用程序不再被阻止(我想因为WL.Client.connect异步运行而WL.Client.init没有,但它只是我的意见)。

i set to false connectOnStartup and left only the call to WL.Client.connect. Now the app doesn't get blocked anymore(i suppose becouse WL.Client.connect runs asynchronously while WL.Client.init does not but it's only my opinion).

我还无法连接到服务器,这很奇怪因为(你可以在图片中看到)有一个listview填充了sql适配器返回的数据,

i can't connect to the server yet, this is strange becouse(you can see in the pic) there is a listview filled with data returned by a sql adapter,

所以看起来应用程序可以连接到服务器以调用适配器但不能用于更新

so it looks like the app can connect to the server for calling adapters but not for updates

推荐答案

您已在 initOption.js 中设置 connectOnStartup:true ,这意味着应用程序将尝试在启动时连接到Worklight Server - 基本上它调用 connect ,那么为什么要调用 WL.Client.connect in wlCommonInit()以及?

You have already set connectOnStartup:true in initOption.js, this means that the app will try to connect to the Worklight Server on startup - basically it calls to connect, so why do you call WL.Client.connect in wlCommonInit() as well?

至于onSuccess和onFailure,我认为您可能想要的是以下内容:

查看WL.Client.init的选项

As for the onSuccess and onFailure, I think that in this what you may want is the following:
See the options for WL.Client.init.

你有一个initOption可以取消注释 initOptions.js

There is an initOption that you can uncomment in initOptions.js:


  • onConnectionFailure

  • onConnectionFailure

连接到Worklight
服务器时调用的故障处理函数,在初始化时执行默认情况下,或者如果
connectOnStartup标志为true,则失败。

A failure-handling function invoked when connection to the Worklight Server, performed on initialization by default, or if the connectOnStartup flag is true, fails.

默认情况下成功为 wlCommonInit(),但是你想要其他东西然后在 initOptions.js 你还可以添加 onSuccess:

The "success" by default is wlCommonInit(), but you want something else then in initOptions.js you can also add onSuccess: something.

BTW,你在哪里看到你所做的最佳实践 通过Worklight?

BTW, where did you see what you've done as a "best practice" by Worklight?

这篇关于Worklight - 启动时连接失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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