Page 1 of 1

Web View Resources

Posted: Fri Apr 08, 2016 12:43 pm
by soapagent
Can you point me at an example of using the resouces property of a web view. I want to download and cache a couple of js files and a css file.

Re: Web View Resources

Posted: Fri Apr 08, 2016 2:40 pm
by tsupartono
Please find below an RDMLX example of using the 'Resource' property to download HTML (JS & CSS) files and run them locally.
Attached ZIP file contains the resource & schema folder that you need to place under your LongRange folder.
This example shows how to run a webpage locally, and reference two local resources (CSS & JS).

Bear in mind as well that the purpose of the Resource property is to get the items available locally and accessible by an offline HTML.
If you just want caching but your form is still an online form (e.g. RDMLX), you'd be better off to just use the WebView's builtin caching mechanism (as long as your web server sets the correct caching directive for the CSS and JS files).

Files downloaded using 'Resource' property won't get updated automatically if you update the copy on the server (your users would have to manually do a schema refresh), whereas the WebView's builtin caching mechanism would (but depends also on your caching directive from the web server).

Code: Select all

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #LRNG_FORM)

* ========================================================
* Start of Executable Code
* ========================================================
Mthroutine Name(HandleRequest) Options(*REDEFINE)

#COM_OWNER.Set Property('/Form.Grid.Col%1.Width') To('Fill')
#COM_OWNER.Set Property('/Form.Grid.Row%1.Height') To('Fill')

#COM_OWNER.Using Element('/Form.Fields.MyWebView')

#COM_OWNER.Set Property('Type') To('WebView')
#COM_OWNER.Set Property('Url') To('local_page.html')
#COM_OWNER.Set Property('Resource%1') To('local_script.js')
#COM_OWNER.Set Property('Resource%2') To('local_styles.css')

#COM_OWNER.EndUsing

Endroutine

End_Com

Re: Web View Resources

Posted: Fri Apr 08, 2016 3:38 pm
by soapagent
Thanks for the advice.

I was basically looking for the most efficient way of getting the libraries down. I'm in an offline form and I've basically implemented it as you suggested while waiting for this response.