Page 1 of 1

Signal event from View to Main Web Page

Posted: Thu Jul 28, 2022 3:24 am
by adale
I have an odd issue with SIGNAL EVENT, that maybe someone can lend some help.
In VL Web, I want to navigate from one View to a different View. I was originally using the #SYS_WEB.Routing.Navigate, but this was not always working correctly, and Lansa support said to use Signal events back to the Main Web page, and have all navigation be performed from it.
OK, in my test VL app (simple, no log in required) all works fine.

In my work VL Web app, I have basically the same set of code, but the Main Web page does not respond or seen to even recognize the signaled event?
The one big difference between my work app, and the test app, is that in the work app it is login protected. Is anyone aware of access protected, protected routing having an impact on Signal events?

Here is what I have in my View to trigger the Signal Event (Marco)
* Defined the Signal event to return to Main page for Autoplay
DEFINE_EVT Name(GoToNextAP)

* Signal event triggered from MthRoutine (not Evtroutine)
MTHROUTINE Name(GoToNextTopic)
SIGNAL Event(GoToNextAP)
ENDROUTINE


Then in my Main Page, here is where I am expecting to respond to the Signal Event (Polo)
* Views with signal events - Polo to listen for signaled events
DEFINE_COM Class(#KX2Welcome) Name(#Welcome)


EVTROUTINE Handling(#Welcome.GoToNextAP)
* Console - debug
#sys_web.Console.Log( ('LINE-182 KX2Main: ' + ' - ' + #KX2SessionProperties.UserNextTopic) )
* Pause to let any component finish before navigating to new view
#Timer1.Start
ENDROUTINE

EVTROUTINE Handling(#Timer1.Tick)
* test timer delay
#Timer1.Stop
* Navigate to new view
#SYS_WEB.Routing.Navigate Path('/' + #KX2SessionProperties.UserNextTopic)
ENDROUTINE

When I execute the VL web app, and GoToNextAP signal event from the View is triggered, the sys_web.console message never is populated, and the navigation does not happen. No errors that I can find, it just seems to be ignoring the Signal event???

Any help or insight is appreciated.

Re: Signal event from View to Main Web Page

Posted: Fri Jul 29, 2022 9:36 am
by BrendanB
Arlyn,

an alternative to signalling to the webpage:

In your *WEBPAGE*

Code: Select all


Mthroutine Named(GoToNextAP)
* your code to deal with it..
Endroutine

In your *VIEW*

Code: Select all


*note - no define_com needed for the webpage...
#Mywebpage.GoToNextAP

That is -- you can *CALL* a method that exists in a Webpage.

Typically:
1. Signal an event if your view just needs to let *EVERYONE LISTENING* know that something happened.
2. Call a method if your view *needs* to have something happen (ie. in your case, the view *needs* the webpage to do something).

-- 1. View/RP does not need/know/expect *any other component* to react to the SIGNAL (View is standing in a room shouting 'I have money')
-- 2. View/RP *needs another component* to do something (View walks up to bartender and says 'give everyone a soda')

you may not have been aware that you can simply reference your webpage (without needing to put a DEFINE_COM in your view) -- so yes, you can also DEFINE_PTY in your WEBPAGE, and reference those properties in your components (views or data models).

NOTE: this does not work from a SERVER MODULE.

so in summary: I would preference calling a method because your view *needs the webpage to do something*.

Re: Signal event from View to Main Web Page

Posted: Sat Jul 30, 2022 2:45 am
by adale
Brendan,
Thanks for the advice and excellent explanation, it certainly helps.
I understood the Signal to be a blind "Marco - Polo" kind of situation, but did not know you could call a Mthroutine in the main web page directly, and will give this a try.
Thanks again.

Re: Signal event from View to Main Web Page

Posted: Thu Jul 03, 2025 12:49 am
by adale
Is there a means to call or trigger a PTYROUTINE, aside from the SET or GET in the DEFINE_PTY?
I want to have an EVTROUTINE listening for a changed event from a dialog, and then update or run the PTYROUTINE.

Re: Signal event from View to Main Web Page

Posted: Thu Jul 03, 2025 4:17 am
by kno_dk
Hi.

Have you looked at the globaldataobject?

/klaus