Reusing Existing Code

One of the advantages of using a Component Interface is that it enables you to reuse existing PeopleCode and business logic. However, a Component Interface isn’t exactly equivalent to a component, which means there are a few key areas in which you should expect differences in behavior between a Component Interface and the component it is based on. This section discusses these differences.

When you run a Component Interface, the SearchInit, SearchSave, and RowSelect events don’t fire. This means that any PeopleCode associated with these events won’t run. The first event to run is RowInit.

PeopleCode events and functions that relate exclusively to the page interface (the GUI) and online processing can’t be used by Component Interfaces. These include:

  • Menu PeopleCode and pop-up menus.

    The ItemSelected and PrePopup PeopleCode events are not supported. In addition, the DisableMenuItem, EnableMenuItem, and HideMenuItem functions aren’t supported.

  • Transfers between components, including modal transfers.

    The DoModal, EndModal, IsModal, Transfer, TransferPage, DoModalComponent, TransferNode, TransferPortal, and IsModalComponent functions cannot be used.

  • Cursor position.

    SetControlValue cannot be used.

  • WinMessage cannot be used.

  • Save in the middle of a transaction.

    DoSave cannot be used.

  • The page Activate event cannot be used.

When executed using a component interface, these functions do nothing and return a default value. In addition, using the Transfer function terminates the current PeopleCode program.

For the unsupported functions, you should put a condition around them, testing whether there’s an existing Component Interface.

If %ComponentName Then
   /* process is being called from a Component Interface */
   /* do CI specific processing */
   /* do regular processing */
   .  .  .

If you associate a Component Interface definition with a menu in Application Designer, a PeopleCode program that conditionally checks for that menu runs when the Component Interface is executed. For example, suppose you associate a Component Interface with the MP_HR_MENU. The following PeopleCode program, if called from that Component Interface, executes:

If %Menu = MP_HR_MENU Then