IBM Worklight - How to change the url of the worklight server dynamically

末鹿安然 提交于 2019-12-07 17:29:55

问题


I need to customize a screen where the user can inform the worklight server ip in client-side. I can change the url connection dynamically? I know that pressing the menu button in android, there is the option of informing the url, but i want custom screen.


回答1:


Technically speaking it is possible to change the Worklight Server URL that the application connects to, but things can and likely will go wrong and it is absolutely not supported by IBM Worklight.

As for creating some UI for it, that's on you.

See this answer by Anton: Re-route/Divert some WL.Client Adapter Invocation traffic to WL Server through different URL (for PCI payment and security requirements)?

Also see the following questions:

  • IBM Worklight - How to use Custom Server URL?
  • IBM Worklight - How to customize an app after creating its .api/.apk?
  • Worklight Apps pointing to different Worklight Servers



回答2:


For Worklight v6.1, you can set below properties dynamically:

WL.StaticAppProps.APP_SERVICES_URL = your URL + WL.StaticAppProps.POSTFIX_APP_SERVICES_URL;

WL.StaticAppProps.WORKLIGHT_ROOT_URL = your URL + WL.StaticAppProps.POSTFIX_WORKLIGHT_ROOT_URL;

WL.StaticAppProps.WORKLIGHT_BASE_URL = your URL;




回答3:


if you dig into the worklight.js file there is a function "setWLUrl(url)" that can be use to chnange the serevr URL. call it like this and its done

setWLUrl("http://"+yourServerIP+":PORT");

its kind a hack but i think it should not have anny issue since its a function within there api.

Good Luck



来源:https://stackoverflow.com/questions/20883345/ibm-worklight-how-to-change-the-url-of-the-worklight-server-dynamically

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