Page 1 of 1

Calling Server Routine from HTML/Javascript

Posted: Thu Aug 10, 2017 8:20 am
by caseywhite
If I have a static HTML page as the home page with the user/password fields and a login button, is there an easy way to call a VL SRVROUTINE that will validate the user and password. That SRVROUTINE will then do *WEBPAGE response to take the user to the VL Web home page.

This is a more generic question though of how to call SRVROUTINEs from something other than a VL Web page or reusable part.

Is it possible. Is there any info int he docs about this?

Re: Calling Server Routine from HTML/Javascript

Posted: Thu Aug 10, 2017 8:59 am
by BrendanB
Search the docs.lansa.com for JSON Convenience Wrapper

Whilst this is specifically for talking to WAM (webroutines), the mechanism is basically identical for SRVROUTINEs.

Re: Calling Server Routine from HTML/Javascript

Posted: Thu Aug 10, 2017 9:08 am
by caseywhite
Thanks. Will take a look.

Re: Calling Server Routine from HTML/Javascript

Posted: Thu Aug 10, 2017 9:23 am
by soa
What is a SRVROUTINE response of *WEBPAGE. I can find a few references to but no full explanatiom of how it works.

Re: Calling Server Routine from HTML/Javascript

Posted: Thu Aug 10, 2017 10:03 am
by Stewart Marshall
By default, a SRVRoutine returns the data as JSON, meaning that the web application works more like a traditional client server app.

*WebPage, followed by the name of the desired WebPage, means that you get a completely new page served to the browser.

Re: Calling Server Routine from HTML/Javascript

Posted: Thu Aug 10, 2017 12:41 pm
by soa
Thanks Stewart

Would that be a static web page xxxx.html served off the current server or any arbitrary page eg. www.smh.com.au?

Are there any examples anywhere?

Re: Calling Server Routine from HTML/Javascript

Posted: Thu Aug 10, 2017 3:17 pm
by Stewart Marshall
Hi Jim

It's neither of those. It's a WebPage component.

Code: Select all

Srvroutine Name(SignedIn) Response(*WebPage #MainApplicationWebPage)

Endroutine
An example might be that you use the first page to manage signing in to the application. Assuming success, you can execute the SRVRoutine. This will then return the new page, completely replacing the signon page.

If you want to navigate to a static page or a different domain

Code: Select all

#sys_web.Navigate( "http://www.smh.com.au" Current )
Regards

Re: Calling Server Routine from HTML/Javascript

Posted: Sat Aug 12, 2017 9:36 am
by caseywhite
Stewart, would I use the same JSON convenience wrapper from a WAM if I want to call a Web Page and Post parms? The Web Page and WAM will be in the same session and needs to be able to post some parms to the web page. I don't want to pass them in the URL. Is there an easy way in a push button weblet to call a server routine or is the JSON convenience wrapper the only way for a WAM to call a server module that that then redirects to a web page.

Re: Calling Server Routine from HTML/Javascript

Posted: Mon Aug 14, 2017 10:23 am
by dannyoorburg
Hi,

I think you can.

I'm pretty sure you can just pass in ServerModule/ServerRoutine where you would normally pass WAM/WebRoutine to the push button Weblet and have your ServerRoutine return a WebPage component as the next page.

Give it a try.

Cheers,
Danny

Re: Calling Server Routine from HTML/Javascript

Posted: Tue Aug 15, 2017 1:23 am
by caseywhite
I tried that before posting but had an issue so thought it wasn't supported. Realized that you cannot use the name in the WAM/Webroutine of the push button but instead must use the ID of the WAM. Now it works. Thanks.