A script-enabled browser is required for this page to function properly.

Enabling and Handling JavaBean Events with Enhanced JavaBean Support

The enhanced JavaBean support can handle events coming from the JavaBean and react to them in the Form. Listeners for bean events can be registered at runtime by the Form. When an event listener has been registered, firing of the event will result in the execution of the WHEN-CUSTOM-ITEM-EVENT trigger in the Form. Information about the event will be made available through the system variable :SYSTEM.CUSTOM_ITEM_EVENT and the parameter list exposed through :SYSTEM.CUSTOM_ITEM_EVENT_PARAMETERS.

Subscribing to Events with FBean.Enable_Event

To register a particular event with the enhanced JavaBean support, use the FBEAN.ENABLE_EVENT() Built-in for the relevant instance of the Bean Area. Like other Built-ins, FBEAN.ENABLE_EVENT() takes the name/id and instance number of the Bean Area, and also takes the name of the event listener that is being subscribed to, for example, keyListener. To subscribe to a particular event, set the final argument to this Built-in to a Boolean value TRUE. To suspend your subscription to the event you can call the Built-in again with the Boolean value FALSE.

For example, to enable the Mouse Click event on the Juggler JavaBean call the Built-in for mouseListener with a final argument of TRUE.


FBean.Enable_Event('MyBeanArea',1,'mouseListener', true);

To react to the above event, attach a WHEN-CUSTOM-ITEM-EVENT trigger to the Bean Area to process the event information as passed in :SYSTEM.CUSTOM_ITEM_EVENT and :SYSTEM.CUSTOM_ITEM_EVENT_PARAMETERS. The event name itself is passed in the :SYSTEM.CUSTOM_ITEM_EVENT value, and the payload of the event is passed in the DATA parameter in the parameter list defined by :SYSTEM.CUSTOM_ITEM_EVENT_PARAMETERS.

The following example parses the mouse event string into its parts and then stops the juggler if there was a double-click on the JavaBean


declare
    EventData VARCHAR2(255);
    XPos number;
    YPos number;
    ClickCount number;
    IndexStart PLS_INTEGER;
    IndexOffset PLS_INTEGER;
    ParmType NUMBER;
  begin
    --Is this the event we are interested in?
    if :SYSTEM.Custom_Item_Event = 'MOUSE_CLICKED' then 
      -- get the DATA parameter that contains all the information  
        -- about the event
      get_parameter_attr(:System.Custom_Item_Event_Parameters, 
  'DATA',ParmType,EventData); 
  
      -- Parse the data parameter String based on Commas and spaces
      -- first argument is the mouse position as an X, Y pair separated by a space
        -- So split that
      IndexStart := 0;
      IndexOffset:= instr(EventData,' ',IndexStart);
      XPos := to_number(substr(EventData,IndexStart,IndexOffset));
      IndexStart := IndexStart + IndexOffset + 1;
      IndexOffset:= instr(EventData,',',IndexStart) - IndexStart;
      YPos := to_number(ltrim(substr(EventData,IndexStart,IndexOffset)));
  
      -- 2nd arg is the clickcount - that is. single- or double-click event
      IndexStart := IndexStart + IndexOffset + 1;
      ClickCount := to_number(substr(EventData,IndexStart)); 
   
      -- If double click then stop juggling
      if ClickCount = 2 then 
        FBEAN.INVOKE('MyBeanArea',1,'stopJuggling');
      end if;
    end if;
  end;
  

Notes on JavaBean Events: