This is a bunch of tips and techniques related to Oracle PL/SQL and Forms.
Purpose
This is a Javabean component that allows to replace the internal Oracle Forms’ timer

The java code
| package oracle.forms.demo; import oracle.forms.handler.IHandler; import oracle.forms.ui.CustomEvent; import oracle.forms.properties.ID; import oracle.forms.ui.VBean; import oracle.forms.engine.Main; import oracle.forms.engine.*; import oracle.forms.handler.*; public class Timer extends VBean implements Runnable { static Thread runner ; static int seconds = 0 ; static IHandler mHandler; protected static final ID TIMEREXPIRED = ID.registerProperty("TimerExpired"); protected static final ID pInitTimer = ID.registerProperty("initTimer"); protected static final ID pStartTimer = ID.registerProperty("Start"); protected static final ID pStopTimer = ID.registerProperty("Stop"); public Timer() { super(); } public void init(IHandler handler) { super.init(handler); mHandler = handler; System.out.println("*** oracle.forms.demo.Timer Init ***") ; } private void startTimer() { if (runner == null ) { runner = new Thread(this); runner.start(); } } private static void stopTimer() { if (runner != null ) { runner = null; } } public void run() { Thread theThread = Thread.currentThread(); while (runner == theThread) { try{ Thread.sleep(seconds); } catch (InterruptedException e) { } dispatch_event() ; } } public boolean setProperty(ID _ID, Object _args) { if(_ID==pInitTimer) { System.out.println("milliseconds=" + (String)_args) ; seconds = new Integer((String)_args).intValue() ; return true; } else if (_ID == pStartTimer) { System.out.println("Start") ; startTimer() ; return true; } else if (_ID == pStopTimer) { stopTimer() ; return true; } else { return true; } } public void dispatch_event() { CustomEvent ce = new CustomEvent(mHandler, TIMEREXPIRED); dispatchCustomEvent(ce); } } |
Forms configuration
Implementation Class property
oracle.forms.demo.Timer
Properties that can be set
The frequency of expiration
set_custom_property( 'BLOC3.BEAN_ITEM', 1, 'initTimer', 'number_of_milliseconds');
Start the timer
set_custom_property( 'BLOCK.BEAN', 1, 'Start', '');
Stop the timer
set_custom_property( 'BLOCK.BEAN', 1, 'Stop', '');
The sample dialog
This dialog allows to enter the frequency of the timer, start (showing the time in real-time) and stop the timer.
The code that captures the java event is located in the WHEN-CUSTOM-ITEM-EVENT trigger of the bean item.
| :BLOCK2.HEURE := SYSDATE ; Synchronize ; |