WebView

Q:
In my webview, I’ve defined a hyperlink field (“hyperlinks=id”)

Code:
lib:/report.rsp?database=sfm&table=documenti&heading=Documenti aperti&fields=keylookup("Clienti", "id", keylookup("Progetti", "id", documenti.progettoid, clienteid), cliente),keylookup("Progetti", "id", documenti.progettoid, progetto),id,caso,priorita,descrizione,stato&headings=Cliente,Progetto,N Documento,Caso,Priorita,Descrizione,Stato&hyperlinks=id&gridlines=false

then I’ve flagged my “delagate hiperlink” and in the “delagate script”
Pagina_attivita_in_corso_Sezione_attivita_in_corso _linkclicked

then I’ve write my function:

Code:
////////////////////////////////////////////////////////////////
// Event delegate for 'linkclicked' event
proc Pagina_attivita_in_corso_Sezione_attivita_in_corso_linkclicked(arg)
        // insert your code here
        m_filtro = "page:documento.documento_documento?action=search&text=" + arg
        
        ? "m_filtro = " + m_filtro
                
        Lianja.showDocument(m_filtro)
        Lianja.showDocument("page:documento.documento_documento?action=show")   
endproc

when I click on my hyperlink, the args is empty..

A:
In the rsp file (backup the file if you are using the default lib:/report.rsp and remember that it will be overwritten by the installer) change the lines:

to

Code:
if len(target) > 0
        ?? ('&(space)' + m_link + '')
else
        ?? ('&(space)' + m_link + '')
endif

Q:
Can I use Lianja.evaluate to set a value on a canvas section from a webview
I would like to set a textbox on a canvas section with that variable value.
Using Linja.evaluate(“page.section.object”), I can get the current value of the textbox like so

Code:
var p = Lianja.evaluate('Lianja.get("page1.section1.txt1").value');
Lianja.showMessage(Lianja.evaluate(p));

However, I don’t seem to be able to set the value.

A:
As this is desktop you can use Lianja.execute( )
Lianja.evaluate( ) is for evaluating expressions.
Lianja.execute( ) is for executing Lianja/VFP commands.
Note that the Lianja system object is system wide across all sections in an app so you can perform operations on any UI elements directly. You only need to reference them with Lianja.get( )


Q:
I’ve declared some variables to be used by the whole app in a JS page specified as the custom library in the app settings. Works totally fine accessing and mutating them from within pages, sections and so on. Now I’m building a webview section to display these variables in a nice, CSS’d format. Problem is, when I try to print the variables to the webview’s html with javascript, it’s telling me they aren’t declared. Obviously they are, so it’s not seeing the variables declared in the app’s custom library.
lib_myapp.js

Code:
var myglobal = "abcd";

page1_section1.jssp:
Name: Screenshot - 22.2.2017. , 8_49_58.png Views: 0 Size: 2.4 KB

s it even possible to access those variables from the javascript on a JSSP page?
A:
Custom library code runs in the client.
WebViews have their own context although you can use the Lianja system object from any JavaScript that is generated and runs within that context.
Passing client side data to server pages should be done as parameters that should preferably be base64 encoded and if passing many of them added to an object which is JSON encoded on the client and JSON decoded on the server.
So to summarize. Considering a Webview is generated remotely it has no direct access to client side JavaScript variables.


If you are ever stuck in a webview section, right click it and use the inspector, it will let you know where your issue is.
If you are not sure how to use it, here is link that may be useful.
https://developer.chrome.com/devtools



Q:
I’m tryng to create a HTML Editor server page.
I’ve created a page, with a WebView section, saved as a Server Page.

Question:
is possible to force the ControlSource of the webview section?

I’ve try with:

Code:
public Ps_ControlSource
Ps_ControlSource = "articoli.abbinamenti"
lianja.showdialog("EditorHTML", "EditorHTML")   
release Ps_ControlSource

then, in the Load of EditorHTML page:

Code:
section = lianja.get("section1")
value = Ps_ControlSource
section.ControlSource = value

but not work..
controlsource is a RW property of webview, but i I type:

Code:
a = lianja.get("EditArtCarTesto.section1")
? "-" + a.controlsource + "-"

I get: —
A:

Code:
a = lianja.get("EditArtCarTesto.section1").webview

 

Remember that you can change the attributes of the section and also those of the UI element inside it so you need to reference the element contained within the section which is a container.


A Webview section in a desktop app is not connected to an http server.
Attempting to use a FileReader is only valid in a web browser client not a desktop app with an embedded Webview.
The desktop client has a web server running internally in port 8002


Q:
I’ve a difference from Webview and printed webview.


If I print with:
Webview.printpreview(GETPRINTER(), ‘PORTRAIT’, ‘NATIVE’, ”, ‘A4’, 1)
then print from the preview..
not work.
A:
google this “a4 size in pixels” and experiment.

72 dpi (web) = 595 X 842 pixels
300 dpi (print) = 2480 X 3508 pixels (This is “A4” as I know it, i.e. “210mm X 297mm @ 300 dpi”)
600 dpi (print) = 4960 X 7016 pixels
Try generating as a “PDF” rather than “native”
http://www.lianja.com/doc/index.php/EXECRSP()

also, you need to specify the output filename for the PDF file. Read the doc for WebView print()

http://www.lianja.com/doc/index.php/Webview
Webview.print(GETPRINTER(), ‘PORTRAIT’, ‘PDF’, ‘c:\temp\schedaarticolo.pdf’, ‘A4’, 1)


Q:
In a desktop application, I have a web view section and a canvas section.
How can I reference an id in the webview section from the canvas section?
A:
The WebView section has an evaluate() method which lets you execute JavaScript inside it.
evaluate() document.getElementById(‘name’).value;


Q:
access to the webview objects from outside the webview.

Meaning – If I want to change the innerhtml of an item in the webview from a canvas section how can that be accomplished.

I guess another way to ask the same question is what is the hierarchy of webview in the LOM/DOM

something like Lianja.page1.document.getElementById(“Title”).inne rHTML = “New Title!”;
A:
reference to the WebView section in Lianja.

myview = Lianja.getElementByID(“page1.section1”).webview

If you define a JavaScript function in your WebView HTML using a

Advertisements