PROCESS PAGE in a REPEAT loop

More often than not, a Natural application organizes its I/O processing in a REPEAT loop. Doing this with Natural for Ajax, we would result in a program structure like the following:


DEFINE DATA LOCAL
1 MESSAGE (A) DYNAMIC
END-DEFINE
*
REPEAT
*
  PROCESS PAGE USING "A3392"
*
  DECIDE ON FIRST *PAGE-EVENT
*
    VALUE U'nat:page.end'
      IGNORE
*
    VALUE U'onButton1'
      MESSAGE := 'Button 1 was pressed.'
      ESCAPE TOP
*
    VALUE U'onButton2'
      MESSAGE := 'Button 2 was pressed.'
      ESCAPE TOP
*
    VALUE U'onButton3'
      MESSAGE := 'Button 3 was pressed.'
      ESCAPE TOP
*
    NONE VALUE
      PROCESS PAGE UPDATE
*
  END-DECIDE
*
END-REPEAT
*
END

However, we are not able to set a message in the status line with this code structure, because the PROCESS PAGE statement lacks a SEND EVENT clause. An option to overcome this situation is setting the status message in an extra event that is triggered by a timer control, as shown below:


DEFINE DATA LOCAL
1 SHOWMESSAGE (A) DYNAMIC
1 MESSAGE (A) DYNAMIC
END-DEFINE
*
REPEAT
*
  PROCESS PAGE USING "A3392"
*
  DECIDE ON FIRST *PAGE-EVENT
*
    VALUE U'nat:page.end'
      IGNORE
*
    VALUE U'onButton1'
      MESSAGE := 'Button 1 was pressed.'
      SHOWMESSAGE := '1'
      ESCAPE TOP
*
    VALUE U'onButton2'
      MESSAGE := 'Button 2 was pressed.'
      SHOWMESSAGE := '1'
      ESCAPE TOP
*
    VALUE U'onButton3'
      MESSAGE := 'Button 3 was pressed.'
      SHOWMESSAGE := '1'
      ESCAPE TOP
*
    VALUE U'onShowMessage'
      SHOWMESSAGE := '0'
      PROCESS PAGE UPDATE FULL
        AND SEND EVENT 'nat:page.message'
        WITH PARAMETERS
          NAME 'type' VALUE 'S'
          NAME 'short' VALUE MESSAGE
        END-PARAMETERS
*
    NONE VALUE
      PROCESS PAGE UPDATE
*
  END-DECIDE
*
END-REPEAT
*
END

This method costs an additional roundtrip to the server, but allows to overcome the above restriction. The full example code is contained in the attached zip file.
NRT3392.zip (15.6 KB)