Results 1 to 9 of 9

Thread: Webview in web app

  1. #1
    Senior Member
    Join Date
    Jan 2014
    Posts
    369

    Webview in web app

    Hi guys

    Converting Lianja/VFP app to a js web app and have a couple of questions re webviews

    In the Lianja/vfp version we use a webview section that calls a Lianja server page .rsp

    We then issue :

    cTmpnam = "somefilename.pdf"
    oWebView = Lianja.getElementByID("pageOrder.sectionwebview")
    oWebView.print("","Portrait","PDF",cTmpnam,"A4",0, 1920,1080)
    showdocument("File:///"+cTmpnam)

    which creates and then displays a pdf file. As the file is saved on the local hard drive we can then email it.


    Questions :

    1) In a js web app, can we use the same .rsp file or do we need to convert it to a .jssp?

    2) are we right to be using a webview section, rather than a webview gadget on a form section?

    3) In js, we are trying to call the identical :


    var cTmpnam = "somefilename.pdf";
    oWebView = Lianja.getElementByID("pageOrder.sectionwebview");
    oWebView.print("","Portrait","PDF",cTmpnam,"A4",0, 1920,1080);
    showdocument("File:///"+cTmpnam);

    which works fine on desktop but output is blank when tested in web when printed or saved to pdf but does not create a PDF file



    3) As browsers are not allowed to save a file to the local hard drive programatically (sandboxing?), presumeably we would have to save it manually each time. how can we email the resultant file when it is created?

    Thanks in advance


    SpringBox
    Last edited by SpringBox; 2021-08-23 at 07:52.

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi SpringBox

    a browser which may be operating remotely cannot access files on the local filesystem like that.

    you use the print() method on the WebView section which will let you choose the print target on the client.

    alternatively createobject(“webview”) in your server side code and execute the print method to the pdf to a file on the server not the client.

    Lianja has built-in email functions. See sendmail() in the doc.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Hi Barry

    Thanks - that works great - now built the full file production and email sending functionality into a .prg file called from the js menu delegate.

    However, when we test the same code in a browser, the vfp statement in the server side proc

    oWebViewServer = createobject("webview")

    creates an error (404 page not found). Is there anything different that we have to do to instantiate the webview object on the server side in web?

    Thanks in advance


    SpringBox

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi Springbox

    no, what is the error message.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  5. #5
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Hi Barry

    Stripped function down to bare bones.

    In js, we call

    var lemailorder = Lianja.evaluate("emailtest()");


    emailtest.prg is just one line :

    oWebViewServer = createobject("webview")


    and the browser error is :

    jquery-1.10.2.min.js?_v=6.2.1.1053-1629879835979:6 GET http://localhost:8001/odata/?$eval=emailtest()&$app=abcenergy&_=1629879837990 404 (The requested page was not found)
    send @ jquery-1.10.2.min.js?_v=6.2.1.1053-1629879835979:6
    ajax @ jquery-1.10.2.min.js?_v=6.2.1.1053-1629879835979:6
    evaluateSync @ LianjaHtmlClient.js?_v=6.2.1.1053-1629879835979:1151
    evaluate @ LianjaHtmlClient.js?_v=6.2.1.1053-1629879835979:1189
    window.Lianja.evaluate @ LianjaHtmlClient.js?_v=6.2.1.1053-1629879835979:25556
    pageOrder_sectionOrderForm_customsectionmenu @ lib_abcenergy.js?_v=1.0.1053-1629879835979:731
    onclick @ index.html?_v=6.2.1-1.0.1053-1629879837028:2538
    LianjaHtmlClient.js?_v=6.2.1.1053-1629879835979:1161 evaluateSync failed: emailtest(), url=/odata/?$eval=emailtest()&$app=abcenergy


    When we type oWebViewServer = createobject("webview"); in to the browser console it seems fine and shows all the properties & methods

    Any thoughts?


    Simon
    Last edited by SpringBox; 2021-08-25 at 06:25.

  6. #6
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi Springbox

    It appears the "webview" is currently disabled in the server.

    An alternative woud be to create a web socket server that uses a web view to generate the pdf and email it.

    See doc.
    https://www.lianja.com/doc/index.php/Websocket

    and run your web socket server as a background task.

    https://www.lianja.com/doc/index.php/Background_Tasks

    I will look into adding webview into the server in 6.3
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  7. #7
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Hi Barry

    Thanks for reply... Have read everything we can find about websockets and see how that could work but adding another running process is adding considerable complexity.

    Do you think you will be able to add webview into the next release? (Happy to test for you). Using webview is a much more elegant solution and presumably lots of people will want the ability to produce file output from .rsp / .jssp on the server from web/mobile apps and then optionally email the result.

    Will put it on the product enhancement request page too. Fingers crossed.

    Thanks in advance


    SpringBox

  8. #8
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi springbox

    Yes server side WebView has been enabled in Lianja 6.3.

    Lianja includes sendmail() which can be used to email the pdf.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  9. #9
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Brilliant - thanks

    Yes, we've been using sendmail() which works really well.
    Last edited by SpringBox; 2021-08-27 at 05:06.

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