Understanding the Flow controller option

To specify that you want different output pages to appear based on the logic in your program, you define an output parameter as a flow controller. The Flow Controller option is on the Map and Link the Output Parameters to the Output Fields page of the Web Interaction wizard. To open the Flow Control Specification window, click the Value field and then click the button that appears in the field.

You use the Flow Control Specification window to map parameter values to JSP names. During run time, the returned value for these parameters are compared to the values that you specified in this window and causes the run time to display the corresponding page.

If Use error page is selected on the first page of the Web Interaction wizard, then *OTHER is defined in the Value field and error.jsp is in the Output JSP field in the table within the Flow Control Specification window. This means that if the output parameter returns any values not specifically defined in the Flow Control Specification window, then the error.jsp page displays in the browser.

If *OTHER appears in the table, it cannot be deleted or moved up or down in the list. Any new items that you add are placed above *OTHER in the list.

If Use error page was not selected, then the table in the window is empty.

  1. Click New to specify a value and define a JSP page to display when that value is returned as the flow controller from your program. Each value in the Value column must be unique. You can change the JSP files defined in the Output JSP column, including the JSP file defined for *OTHER.

    If you remove a JSP file from your Web project that had been defined as an output JSP file for flow control purposes, the file name still appears in the table in the Flow Control Specification window, but you cannot select it.

  2. Click Remove to remove a selected value and output JSP page from the table.
  3. Use Move up and Move down to rearrange the order of the values and output JSPs in the table.
The following RPG code snippet is an example of using a flow controller. The code checks that a record was selected in a subfile. If it is not selected, an error page is displayed. If it is selected, then the next page is displayed:
   PGetCustRec       B                   export    
   D GetCustRec      pi
   D forward                            20A
   D userinfo                            likeDS(CustInfo)
    *
    * Read the selected record from the CUSTLIST subfile
   C                   Eval      rc=readcSF(CustList):
   C                                        %Addr(CustRec):
   C                                        %Size(CustRec):
   C                                        1)
    * If user didn't select anything
   C                   If        rc < 1
   C                   Eval      forward = "NOSEL"
   C                   Else
   C                   Eval      forward = "OK"
   C                   EndIf
    * If user selected a record ...
   C                   If        rc > 0
                       . . .