NJX:TRIGGEREVENT

The NJX:TRIGGEREVENT control can be used to trigger a server roundtrip between the web application and the Natural server.

Trigger event

The following topics are covered below:


Examples

Common usage scenarios for the NJX:TRIGGEREVENT control are scenarios in which the event reaction of your Natural application consists of several parts which contain data handling and page navigation or pop-up handling. Triggering an event allows you to modularize and combine these different event reaction parts. Some specific sample use cases are described below.

Pop-ups

Your application might want to navigate to a specific page when a pop-up is closed. The navigation may depend on some return value of the pop-up. When the pop-up is closed, the Natural application can trigger an event depending on the pop-up result. In the triggered event, the Natural application can then do the navigation. The following code shows how this can be done:

DECIDE ON FIRST *PAGE-EVENT
 VALUE U'nat:page.end',U'nat:browser.end'
  /* Page closed.
  IGNORE
 VALUE U'onReactionA'
  FETCH RETURN 'MYPRGA'
  PROCESS PAGE UPDATE FULL
 VALUE U'onReactionB'
  FETCH RETURN 'MYPRGB'
  PROCESS PAGE UPDATE FULL
 VALUE U'onOpenMyPopup'
  PROCESS PAGE MODAL
   CALLNAT 'MYPOPUP' MYRETURN
  END-PROCESS
  IF MYRETURN = 'A' THEN
     XCITRIGGEREVENT:='onReactionA'
  END-IF
  IF MYRETURN = 'B' THEN
     XCITRIGGEREVENT:='onReactionB'
  END-IF
  PROCESS PAGE UPDATE FULL
 NONE VALUE
  /* Unhandled events.
  PROCESS PAGE UPDATE
END-DECIDE

Workplace Applications

In a workplace application, you might want to open a logon page as the first page. On logon, your Natural application would dynamically define the function tree of the workplace and after that the logon page should be closed. The following code shows how this can be done:

DECIDE ON FIRST *PAGE-EVENT
 VALUE U'nat:page.end',U'nat:browser.end'
  /* Page closed.
  IGNORE
 VALUE U'onReady'
  /* Close the Login page.
  RESIZE ARRAY XCIWPACCESS2 TO (1:1)
  CMDCLOSECONTENTPAGE(1) := 'closeit'
  PROCESS PAGE UPDATE FULL
 VALUE U'onLogin'
  /* Define the function tree of the
  /* workplace dynamically
  ...
  ...
  /* Trigger the event 'onReady'.
  XCITRIGGEREVENT:='onReady'
  PROCESS PAGE UPDATE FULL
 NONE VALUE
  /* Unhandled events.
  PROCESS PAGE UPDATE
END-DECIDE

TIMER Control

Using the TIMER control, you can automatically trigger an event repeatedly, based on the time interval. When navigating to a different page or when opening a page pop-up, you would like to stop the timer and start it again when returning to the page. This stopping and restarting of the timer can be achieved using an NJX:TRIGGEREVENT control. The following code shows how to stop the timer before opening a page pop-up, and how to restart the timer after closing the page pop-up.

DECIDE ON FIRST *PAGE-EVENT
 VALUE U'nat:page.end',U'nat:browser.end'
  /* Page closed.
  IGNORE
 VALUE U'onOpenMyPopup'
  PROCESS PAGE MODAL
   CALLNAT 'MYPOPUP'
  END-PROCESS
  /* start the timer again
  MYTIMERINTERVAL:=5000
  PROCESS PAGE UPDATE FULL
 VALUE U'onShowDetails' 
  /* Stop the timer 
  MYTIMERINTERVAL:=0 
  /* customize popup settings 
  XCIOPENPOPUP.POPUPTYPE:='PAGEPOPUP' 
  XCIOPENPOPUP.TITLE:= 'Show Details' 
  ... 
  /* trigger an event to open the popup 
  XCITRIGGEREVENT:='onOpenMyPopup' 
  PROCESS PAGE UPDATE FULL 
 NONE VALUE 
  /* Unhandled events.
  PROCESS PAGE UPDATE
END-DECIDE

Adapter Interface

1 XCITRIGGEREVENT (A) DYNAMIC

You have to specify the name of the event to be triggered.