Expected functionality when multiple events are possible

I am relatively new Ajax development and I have recently had a number of problem brought to my attention with code that was written before I started my new position. The problems seem to have their root in the execution of multiple methods from the same trigger action. For example:

a. A field had a flush method on it, data is entered into the field, but the user clicks a button before leaving the field. The flush method is performed and immediately after returning to the page, the button click method is performed.
b. A str control has an on-click method on it as well as a button in the rows of the str control. When clicking the button, the button method is performed, immediately followed by the str onclickmethod.

What is the expected behavior when separate methods are possible based on the same user action?

It seems that suddenly users are reporting problems with code that has not changed because both methods are being executed back-to-back. In December, we upgraded NJX. Is it possible only one of the methods were executed before the upgrade and now both methods execute? I haven’t been in this position long enough to know if the behavior is different or if these applications have always been poorly coded and it is only coincidence that a number of problems have recently presented themselves.


I’ll leave the question re. possible changes between versions in that area for
Christine to answer, just curious of what problems you are facing ?

a. seems pretty straightforward to me and I’d expect the flushmethod to be fired

b. doesn’t sound too strange either, usually an onclickmethod on a str is used to
   display detail information in a different pane or the like, so I wouldn’t expect
   this to cause problems, unless the button method sets something which overlays
   data set by the onclickmethod ?

The problems I am facing is that both methods are being fired and the code wasn’t written in a way to handle it correctly.

For an example of A, there is a series of three fields, the last with a flush method, followed by a button with the same method as the flush. The user enters values (ex 2011 01 1234) in the fields so that the cursor remains in the last of the three fields and a flush method is pending because the third field changed. The method that fires will use the values in the three fields to build a browse then reset the three fields. Tabbing out of the field causes this to work as expected. However, if the user clicks the button with the flush pending, the flush occurs, resetting the three fields, then the button method occurs doing the same thing (except the fields have been reset) so the browse starts from the empty key. Would you have expected the button method to fire too? I’m currently seeing both.

Another example (and far more prominent in this system) is an Exit button that should drop the user out of the process page loop and exit the bottom of the program. If a flush method is pending, the flush occurs, the page is reprocessed, and then the user is dropped out of the program as the exit method happens. The user may not even know what has occurred with the flush, they simply think they exited the program. Were these simply coded poorly? It sounds like your expectation is that the flush wins. You weren’t clear if you’d expect the button method to also occur.

For B, do I understand you to say that you would expect the button click method to execute followed immediately by the str onclick method?

Talking with people who have been working with NJX longer than I have, they feel that getting both methods to fire on a single user action is not what is expected. I can tell you that the existing code suggests they were coding with the expectation that you only get one method (In the case of the exit button, it wasn’t the flush method they were expecting to win).

Thank you Wolfgang.

I would (at least) not expect the button method to be the same as the flushmethod, to be honest.
If all three fields need to be filled to set up the browse what’s the button there for ?

Yes, I’d expect the flush to win as one usually wants validation
to take place unconditionally before anything else happens.

This isn’t clear to me - does the flush trigger updates ?
If it just sets up the browse and displays the result you are burning some CPU cycles for nuffin,
but it can’t cause any real issues, or ?

No expectation really as I haven’t faced a situation like this before, just making my mind up :wink:
I’d say onclick first makes sense.

You are welcome :wink:

My organization uses invoice and job numbers with the format of YYYY MM ##### where X is a sequence number that rolls over at the beginning of the year. I didn’t invent it, I just have to work with it. :smiley: In the example I gave, the intent of having a flush method on the ##### is so that the user doesn’t have to click a button to fill the browse if the user enters all five digits (max length is 5 so the user automatically leaves the field and triggers the flush method). The particular scenario has shown up lately because the ##### has been reset back to 1 with the new year and users are entering 2012 01 1234 for example, then clicking the button. If they entered 2012 01 01234, 2012 01 1234, or 2011 01 1234 there wouldn’t be a problem. Because they are clicking the button, the flush and button methods (in this case the same) are executing. In the same program however, if they click the Exit button, the flush method is executed, then the Exit method executes…still a problem. Developers here when the sequence rolled for 2011 do not feel they experienced this pain then.

By “win” do you mean the first method to be executed or the only method to be executed? What good is the flush “winning” if the other method still executes. The problem may simply be a misunderstanding as to when to use the flush method. Here it is simply being used to save the user from having to click a button (especially when the invoice/job number is being scanned in via a barcode reader).

For the button on an str, I am currently coding a browse that allows the user to delete the record via a button (similar to many other browse screens within the organization). My expectation was to be able to delete the record and give the user feedback via a process page w/ send event clause after the button event occurred. Unfortunately, the row click event was overwriting my message with a message I set for the row click.

I guess from here I’d like to know, if a single user action can trigger multiple events, where can I find information on what the event order is (flush before button, button before str onclick, etc) and is there a way to tell when the flush method is executing that there is another method already up to bat.

I’m beginning to think flush methods and str onclick methods are evil. :slight_smile: Thanks for your help Wolfgang.

I’d expect a flushmethod to be executed first as it’s usually used for verification purposes.
Otoh when clicking an “Exit” button one probably doesn’t want an error message to pop up, so …

Perfectly valid, imho.
When I, as a NJX developer, would have to expect a sequence of events I’d say
row click first makes more sense, and would solve your issue.

Me too curious now, let’s see if some light is shed on this …
I’d suggest creating an incident for this, if you haven’t already.

They definitely aren’t evil per se :wink:

I do have a incident open that is in someway related to this. I recently implemented a change to store the errors our users were seeing to an Adabas file. This change and the upgrade to NJX occurred about the same time so I don’t have pre-upgrade data to compare to. I also don’t think I can trust that the users would have said something if there was a problem. Now that we are capturing the data, we are seeing an odd issue that is somehow tied to a flush method on a field and the clicking of a button.

When the user triggers the flush method by clicking any button on the screen, the code subsequently hits a “input using map” statement and blows up with a NAT6245 (Internal error: name :1: code :2: subcode :3:) error. Whatever is happening, it isn’t nice enough to give the error parameters. The error only occurs if the flush is pending when any button is clicked. If you tab out or completely fill the field so it auto tabs, it goes through the exact same code just fine. Sadly I have had to install a intermediate process page statement between the page and the map and it some how is preventing the error (most of the time, it is down to a couple per day from several dozen). The intermediate page is simply a blank page that is displayed with an XCITRIGGEREVENT set. The user sees a brief blank page then loads the correct page without throwing the NAT6245.

With this incident I will try to get more details on what to expect from “stacked” methods.

New here. And this is also what i expect.

This maybe a good method.By the way,i am new to Ajax,i met some problem withAjax application.
I want to send an e-mail from a Natural for Ajax application in the same way the Java Mail API does for Java applications,but i am confused,any adviced?

Hi Allen,

you have several options to send an E-Mail:

Option 1:

Add an IHTML control to your NATPAGE layout.
Then in the Natural code fill in the corresponding value. For instance the follwoing will open the E-Mail client with corresponding subject and text

Send Email

Option 2:

Add an Adapter Listener to your page and use the Java Mail API to send the E-Mail.

Best Regards,

Option 3:

send the mail from the Backend Natural application.