Web View Resources

Please do not use to report errors- use your regional help desk.
Please mark posts as being for RPG or RDMLX (LANSA) developer.
To subscribe by email, display this forum, scroll to the end and select ‘Subscribe Forum’.
Post Reply
soapagent
Posts: 93
Joined: Mon Jul 16, 2012 6:19 pm

Web View Resources

Post 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.
tsupartono
Posts: 289
Joined: Wed Apr 18, 2012 10:21 am

Re: Web View Resources

Post 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
Attachments
LongRangeFolder.zip
(1.75 KiB) Downloaded 210 times
soapagent
Posts: 93
Joined: Mon Jul 16, 2012 6:19 pm

Re: Web View Resources

Post 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.
Post Reply