Invoking multiple interactions from one input page

You can use a single input page to invoke a different interaction based on user input. For example, if you have a subfile displayed with customer records, and you want the user to be able to select one a record and then press a button to perform an action such as Create, Display, Update, and Delete. You can use the following technique to do this:
  1. On the JSP page that uses an iSeries Table Web component for a subfile, insert a form at the cursor location on a blank line on the page by pressing Ctrl + O.
  2. In the Properties view, add a name for the Form in the Name field. For example, add manage as the form name.
  3. Add four buttons to the form:
    1. Click the Palette tab in the frame on the right of the Web perspective, open the iSeries Web Components menu by selecting the iSeries Web Components drawer, double-click Button to add that iSeries Web component at the cursor location on the JSP page. Go to the Attributes view for the button and change the Button type to Button.
    2. Repeat the previous step to add three more button iSeries Web components to the form.
    3. In the Attributes view enter Create, Display, Update, and Delete as the labels for the four buttons, respectively.
  4. For each of the buttons, add javascript:invoke('function'); for the onClick event on the Events tab in the Attributes view. Replace function with the value that relates to the function of the button. For example, use create for the Create button, and use display for the Display button.
  5. Add an iSeries Text Entry Web component to the form, enter a name in the Name field (for example, enter opcode as the name), and ensure that you change Input Type to Hidden. The hidden attribute ensures that the user does not see this iSeries Web component on the page when it is displayed in a browser.
  6. To add the JavaScript function that sets the value of the hidden field and invokes the interaction, switch to the Source view of the JSP file and add the following JavaScript code prior to the </HEAD> tag:
    <script language="javascript">
            function invoke( op ) {
                    document.manage.opcode.value = op;
                    document.manage.submit;
                    return true;
            }
    </script>
    When the user presses one of the buttons, the onClick event is raised and invokes the invoke JavaScript function. The passed value is put in the hidden field and the form is submitted. This causes the interaction to be called.
  7. Create a procedure that accepts the value of the hidden field as a parameter. In the procedure you then have the code that processes the subfile based on the value passed.
  8. Run the Web Interaction wizard to link the input page with the subfile (represented by the iSeries Table Web component), to the procedure that links the hidden field to a parameter in the procedure.
  9. Also define a parameter that is used for flow control. This flow control parameter is set to a value based on the action to be performed next. For example, assume the user selects a record in the subfile and presses the Delete button. The invoke JavaScript function is called and puts the value delete in the hidden field and submits the form. The interaction is called and it in turn calls the procedure and passes the value of the hidden field. The procedure reads the selected record from the subfile and sets the value of the flow control parameter to DELETE. Since you mapped this value to the delete.jsp page through the Web Interaction wizard, the delete.jsp page is displayed in the browser and prompts the user to confirm the deletion. This page is then used as the input page to another interaction which performs the delete.