Calling Server Routine from HTML/Javascript

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Calling Server Routine from HTML/Javascript

Post 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?
BrendanB
Posts: 134
Joined: Tue Nov 24, 2015 10:29 am

Re: Calling Server Routine from HTML/Javascript

Post 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.
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Re: Calling Server Routine from HTML/Javascript

Post by caseywhite »

Thanks. Will take a look.
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Calling Server Routine from HTML/Javascript

Post by soa »

What is a SRVROUTINE response of *WEBPAGE. I can find a few references to but no full explanatiom of how it works.
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Calling Server Routine from HTML/Javascript

Post 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.
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Calling Server Routine from HTML/Javascript

Post 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?
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Calling Server Routine from HTML/Javascript

Post 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
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Re: Calling Server Routine from HTML/Javascript

Post 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.
dannyoorburg
Posts: 177
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: Calling Server Routine from HTML/Javascript

Post 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
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Re: Calling Server Routine from HTML/Javascript

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