Web Pages - Application(*SCOPE)

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
Joerg Hamacher
Posts: 53
Joined: Thu Feb 11, 2016 12:01 am

Web Pages - Application(*SCOPE)

Post by Joerg Hamacher » Mon Apr 16, 2018 10:23 pm

Hello everybody,

we have an application with several web pages.
In a combining reusable part we define some properties, methods and events that are valid for the complete application.
This reusable part is named SMH_WebApplication and is defines in web pages and reusable parts like this:
Define_Com Class(#SMH_WebApplication) Name(#SMH_WebApplication) Scope(*APPLICATION)

This works fine as long as we work in one window but in some cases it is necessary to open some web pages in a new window using:
#sys_web.Navigate Url(((#Com_owner.GetRootURL) + ("webport_1.html?lang=deu))) Target(New)
In this case all properties that we defined in "SMH_WebApplication" are empty - in spite of defining it as described above.

How can we pass these values to the web pages in the new window?

Best regards,

Posts: 673
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Web Pages - Application(*SCOPE)

Post by jyoung » Mon Apr 16, 2018 11:51 pm

Hey Joerg,

The problem is that the RP is a javascript based object and that javascript is scoped to the page itself. So anything like a page refresh or navigating to a different page that object is going to get downloaded again by the browser and lose any data that it may have contained.

There are typically two ways to persist data across page refreshes or navigation, using the querystring and using session state.

To use the querystring you need to append your parameters to the SYS_WEB.Navigate URL. Then in SMH_WebApplication you can hook into the SYS_WEB.URLChanged event and parse the querystring for your parameters and setup the SMH_WebApplication accordingly.

The cool thing about URLChanged is that it will fire whenever the URL changes AND when the page first loads.
https://docs.lansa.com/14/en/lansa016/p ... hanged.htm

To parse the parameters
https://docs.lansa.com/14/en/lansa016/p ... meters.htm

Something like this perhaps

Code: Select all

#sys_web.Navigate Url(((#Com_owner.GetRootURL) + ("webport_1.html?lang=deu&param1=123&param2=ABC))) Target(New)
Then in your SMH_WebApplication

Code: Select all

evtroutine handling(#SYS_WEB.URLChanged)
for each(#param) in(#SYS_WEB.URLParameters)
case of_field(#param.Name.UpperCase)
when (= PARAM1)
#SMH_WebApplication.Param1 := #param.Value
when (= PARAM2)
#SMH_WebApplication.Param2 := #param.Value
Using the querystring string is IMHO easier, but if you want to use Session State, look into using PERSIST https://docs.lansa.com/14/en/lansa015/c ... ersist.htm and Session https://docs.lansa.com/14/en/lansa016/p ... ession.htm

Hope this helps,
- Joe

Post Reply