understanding events

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
sotos
Posts: 26
Joined: Fri Feb 09, 2018 11:25 pm

understanding events

Post by sotos » Thu Mar 21, 2019 9:14 pm

Hello,

I have encountered the following problem:

We have a web application based on lansas paradigm of signaling
events for switching between reusables (panels).

In a reusable let's say A I have a list and whenever I double click a row we want
the application to switch to another panel (reusable) B and run a function there
than populates some fields an lists on screen.

So my code in A looks like

Code: Select all

Evtroutine Handling(#BROWSE.ItemDoubleClick)

#B.policy := #POLNUM	* poliy is an auto property in reusable B, also B has  Scope(*APPLICATION) in A
#gApplication.Show_INFO	* this hides this screen of A then enables and shouws reusable B and signals the event ShowInfo

Endroutine
The 1st line sets the policy property and the second signals the event ShowINFO (#gApplicaton has also Scope(*APPLICATION))

Within the reusable B I have the following:

Code: Select all

Evtroutine Handling(#gApplication.ShowINFO)

If (#policy > 0)
#COM_OWNER.ResetState()
#POLNUMX := #policy 		* #POLNUMX is a visual field
#COM_OWNER.BeginSearch()	* this returns some info on the screen
Endif
#policy := -1

Endroutine
The problem is that even though the code within BeginSearch() runs normally
the results don't show on the screen.

But whenever the #POLNUMX is hardcoded e.g.

Code: Select all

Evtroutine Handling(#gApplication.ShowINFO)

#policy := 1249469

If (#policy > 0)
#COM_OWNER.ResetState()
#POLNUMX := #policy * #POLNUMX is a visual field
#COM_OWNER.BeginSearch()
Endif
#policy := -1

Endroutine
everything runs fine.

any ideas?

cheers,
Sotiris

atostaine
Posts: 396
Joined: Wed Jan 20, 2016 7:38 am

Re: understanding events

Post by atostaine » Fri Mar 22, 2019 1:31 am

sotos wrote:
Thu Mar 21, 2019 9:14 pm

The problem is that even though the code within BeginSearch() runs normally
the results don't show on the screen.
Have you tried passing the policy with the event? Something like this?

define_evt ShowINFO
define_map for(*input) Class(#policy) name(#pPolicy)

Change this method to also pass the policy
#gApplication.Show_INFO pPolicy(#policy)

Change the evtroutine to get the parm

Evtroutine Handling(#gApplication.ShowINFO) pPolicy(#myPolicy)
#policy := #myPolicy
If (#policy > 0)
#COM_OWNER.ResetState()
#POLNUMX := #policy * #POLNUMX is a visual field
#COM_OWNER.BeginSearch()
Endif
#policy := -1

Endroutine
Art Tostaine

dannyoorburg
Posts: 152
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: understanding events

Post by dannyoorburg » Fri Mar 22, 2019 6:36 am

Hi,

I think this is an example of quite a common mistake....

Your comment says B has scope *application IN A.

There's only ever truly one instance of B if the define_com has the same name and scope *application EVERYWHERE in your app.

So my guess is that that isn't true and you end up setting your property on a different instance than what you think.

Having said that, I would
keep scope *application limited to a single application object for simplicity and go with Art's solution :D

Danny

sotos
Posts: 26
Joined: Fri Feb 09, 2018 11:25 pm

Re: understanding events

Post by sotos » Fri Mar 22, 2019 6:33 pm

Thank you all,

it works now after following your instructions

However now there is another problem that seems like a lansa bug.

When I go back to reusable A, then scroll the list (without using the mouse wheel), at the time the mouse button is released the following appears:

Code: Select all

LANSA Runtime Error:

Cannot read property 'fj' of null
.
.
.

The procedure to go from B to A is similar. There is a button that fires an event:

Code: Select all

Evtroutine Handling(#GAPPLICATION.ShowPRINT)
#COM_OWNER.LoadData()		*This calls #LoadSalpData.ExecuteAsync and #LoadHedpData.ExecuteAsync
Endroutine
that loads the data by calling Asynchronously two server module routines.

To circumvent the problem I defined a trigger that calls #COM_OWNER.LoadData() only if the user did not double clicked previously.

Code: Select all

Evtroutine Handling(#GAPPLICATION.ShowPRINT)
If (#printToInfo = false)
#COM_OWNER.LoadData()
Endif
#printToInfo := false
Endroutine
and within the Itemdoubleclick event of A:
#printToInfo := true

This works fine
but the crash should not be there in the first place.

cheers,
Sotiris

Post Reply