Results 1 to 5 of 5

Thread: [Answers] WebView

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] WebView

    The difference between a WebView and a WebView Gadget is that a WebView is a section in its own right, a custom WebView Gadget is basically a WebView which can be embedded in a Form Section and can share the Section real-estate with other Gadgets and Fields.



    Q:
    In Google chrome, I can open the following file that is local on my desktop.
    file:///C:/Tregister/tempfiles/dilmobile.html
    It seems the webview widget does not let me display the same file.
    A:
    There should be no problem with opening a local file. You may try copying it into an app. It may have relative paths in it which are incorrect. You can right click on the webview to show the web inspector. There is a console tab in there so you will see what errors have been encountered.



    Right clicking on a WebView in development or runtime shows the Web Inspector allowing you to interact with the HTML, CSS and JavaScript.



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2016-03-18 at 02:52.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    WebView sections can occupy a complete page and can contain any content which can be dynamically generated by .rsp or .jssp pages.



    When generating dynamic content for Lianja WebViews using .rsp or .jssp pages you can use Twitter bootstrap to markup the CSS and create responsive content inside your Lianja WebView sections or gadgets.
    This link provides some good tutorials on bootstrap.
    http://www.tutorialspoint.com/bootst...rap_panels.htm
    This can be used in any type of App: Desktop, Web or Mobile.



    Q:
    I do use the printPreview() method then click on the print button to select printer and print.
    A:
    If you are trying to print a Webview section that you have visible in the UI it will be scaled for the printer.
    You need to dynamically create a Webview using createObject("Webview"), set its dimensions to match your paper size then load it with the HTML you generate for a report.
    You should then be able to print correctly.
    When printing a Webview you are not printing characters you are printing the graphics context so the dimensions are important to prevent scaling occurring.
    Try generating the HTML, save it to a file and opening it in your web browser then printing it. Same principal.



    Q:
    What I am loading to the webview section is not a html file but a rsp file. Can I load that rsp file to the webview object?
    A:
    Take a look at execRSP() in the documentation.
    http://www.lianja.com/doc/index.php/EXECRSP()
    This provides you with the ability to generate an HTML file from a .rsp file and output the HTML to a specified file.
    Yes you can specify your .rsp file as the url property on the Webview or as described previously generate an external HTML file using execRSP() to test in a desktop browser.
    You can generate HTML dynamically with .rsp pages by assigning the url of the Webview with the name of the .rsp page.

    Note also that in a .rsp file you can
    substitute expressions using <%= expression %>
    When you print anything this is handled by the printer driver.
    if you have specified the Webview dimensions as described previously and you can print() with the correct paper size then no scaling will occur.
    That particular printer you are using has limited font support so printing from a Webview that has been formatted using HTML is the correct solution.



    Q:
    How to get a German Datepicker for WebAppView
    A:
    A Web or Mobile App can be used by anyone all around the world. The server that remote clients are connected to can be in a different timezone with different date formats.
    The ISO standard for displaying dates is described here:
    https://en.wikipedia.org/wiki/ISO_8601
    The ISO standard Is used by Lianja to display a date or datetime so as to be locale independent. It is nothing to do with being a programmer or not. Its an international standard. Not english, not french, not german, but rather an international standard.
    If you absolutely must have german specific dates displayed then submit an enhancement request.
    The popup calendar can already be customized by language in the App Settings attributes.
    So... That's how you get the dates displayed the way you want it. It will require having a modification made to the web framework to format dates specific to a locale and map them back to ISO when we send data to perform an update on the server.



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352

  3. #3
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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:

    Code:
    if len(target) > 0
            ?? ('<a href="lianja_relatedata:' + lower(alltrim(etos(&target))) + '">&(space)' + m_link + '</a>')
    else
            ?? ('<a href="lianja_relatedata:' + lower(alltrim(etos(&fld))) + '">&(space)' + m_link + '</a>')
    endif

    to

    Code:
    if len(target) > 0
            ?? ('<a href="lianja_relatedata:' + lower(alltrim(etos(&target))) + '">&(space)' + m_link + '</a>')
    else
            ?? ('<a href="' + lower(alltrim(etos(&fld))) + '">&(space)' + m_link + '</a>')
    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: 295
Size:  2.4 KB
    </body>

    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)

  4. #4
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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.

    Code:
    myview = Lianja.getElementByID("page1.section1").webview
    If you define a JavaScript function in your WebView HTML using a <script> tag. It can take an ID and the innerhtml that you want to replace.
    You can then call the evaluate() function to execute your JavaScript function.

    Code:
    myview.evaluate("updateHtml('someid', 'newhtml')")
    Both your onclick and your evaluate need to be enclosed in quotes and you call evaluate() in the WebView not the Lianja system object.
    Code:
    Mycall.evaluate("sayhi()")
    Code:
    mycall = Lianja.getElementByID("page1.section1").webview
    myview.evaluate("sayhi()")




    you can call functions in the WebView using oWebView.evaluate() and those functions can use Lianja.evaluate() inside the WebView function to call other functions in the App. It's a two way interaction.
    And with a little thought one WebView can call functions in another WebView which may be on a different page.



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/showthread.php?2717-Answers


  5. #5
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    It seems that the html file has to be in "C:\lianja\apps\myapp" folder, then we can use that in the URL attribute of a webview section.
    Can we use a html file that is in "c:\lianja\server\temp" folder as the URL source?

    A:
    The URL has to reference a file below the wwwroot, so you could not use c:\lianja\server\temp. If you create a temp folder under wwwroot (C:\lianja\cloudserver\tenants\public\wwwroot\ is the default), then you could specify this folder in the tmpnam() function, e.g.
    Code:
    m.cFile = tmpnam("c:\lianja\cloudserver\tenants\public\wwwroot\apps\myapp\temp\",".htm")
    m.htmlrep = "c:\lianja\cloudserver\tenants\public\wwwroot\apps\myapp\rpt_template.htm"
    m.cStr=FileToStr(htmlrep)
    m.nResult=StrToFile(m.cStr, m.cFile)
    
    return '/apps/myapp/temp/' + justfname(cFile)



    All topics in [Answers] alphabetically: https://www.lianja.com/community/sho...ll=1#post13748

    These answers are also systematized on the site "Lianja developer": https://lianjadeveloper.wordpress.com/category/webview/

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us