0
votes

Using the Worklight v5.0.6 code sample/tutorial "Integrating server-generated pages in hybrid applications" (http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v506/WebViewOverlay.zip) allows for the web content to be integrated. The code sample works fine and web content integrated correctly.

However, when I set connectOnStartup to true in the apps//common/js/initOptions.js file, the tabs and web content from the WebViewOverlay fail to load.

I see in the wlclient.js (apps//android/native/assets/www/default/wlclient/js/wlclient.js) that there is a check that if doConnectionOnStartup is true, then call WL.Utils.wlCheckReachability(), else call finalizeInit()

It appears that the WebViewOverlay and the tabs are created by the finalizeInit() being called, but if connectOnStartup is set true, then finalizeInit is not called.

How can I get both the WebViewOverlay to work and the connectOnStartup to work together?

2
Maybe you can call WL.Client.connect() manually? FYI: There's an answer here that goes over the differences between connectOnStartup and WL.Client.connect.cnandreu
Something is wrong here. I downladed the sampled, changed connectOnStartup to true, and the app continued to work (tabs, overlay and all) wlCommonInit/wlEnvInit should always be called whether connectOnStartup is true or false. Something else must be the problem. Try putting a WL.Logger.debug in wlEnvInit to see if it is getting called at all.David Dhuyveter
Yes, the app does continue to work with connectOnStartup; however, placing an updated wlapp file on the worklight server causes the issue when directUpdate performed. I traced it down to line 820 of worklight.js (apps/<APP NAME>/android/native/assets/www/default/wlclient/js/worklight.js) in that I was seeing the error log message, "WL.SimpleDialog.show() error in invoking callback.". To resolve my issue, I created an entirely separate hybrid app and brought over only the necessary code to support the WebViewOverlay. Now the WebViewOverlay works along with direct updatesJeff Washburn

2 Answers

1
votes

This is, most probably, caused by connection failure. wlCommonInit function will be invoked only after successful connection, in case connection fails it will never be invoked. First of all - check your connectivity from a mobile handset to WL server. Second, you can either manually use WL.Client.connect() after tabbar was initialized (like Carlos suggested) or specify onConnectionFailure callback in your initOptions.

1
votes

I provided what I did above in the comments - but it turned out that the dialog box to indicate an update was available was not showing up, and instead the error message "WL.SimpleDialog.show() error in invoking callback." was seen in the log messages of logcat. This log message is coming from worklight.js (apps//android/native/assets/www/default/wlclient/js/worklight.js) on line 820. Just FYI, I did change the worklight.js code to print out err, and it said "No class found". I didn't take the troubleshooting any further at that point

So the app was contacting the WL Server correctly, but the dialog to indicate an update was available was not appearing.

To fix, I simply created a new hybrid app and brought over the necessary code to get the WebViewOverlay to work