Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

This is a bunch of tips and techniques related to Oracle PL/SQL and Forms.

Publicité

A Javabean timer

Purpose

This is a Javabean component that allows to replace the internal Oracle Forms’ timer


Bean 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

  • . Copy the bean_timer.jar file in the /forms/java directory
  • . Edit the /forms/server/formsweb.cfg file to add the jar file to the archive_jini variable

archive_jini=
f90all_jinit.jar,……,bean_timer.jar

 
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

  • . Download the beantimer.zip file
  • . Unzip the beantimer.zip file
  • . Copy the beantimer.jar file in your /forms/java/ directory
  • . Edit your /forms/server/formsweb.cfg file
  • . Open the bean_timer.fmb module (Oracle Forms 9.0.2)
  • . Compile all and run the module

      

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.



When-Custom-Item-Event
:BLOCK2.HEURE := SYSDATE ;
Synchronize ;
Publicité
Retour à l'accueil
Partager cet article
Repost0
Pour être informé des derniers articles, inscrivez vous :
Commenter cet article
M
good job deserves a great thanks, But WHEN-CUSTOM-ITEM-EVENT still firing after calling a new form, so I faced an error message FRM-41355 "Cannot navigate to form " any help??
Répondre
J
Hello, I have some problem running this example .... when load the form the java console say " *** oracle.forms.demo.Timer Init *** " ( that's ok ) then the login windows appears and when I do login the form throws the next exception : <br /> <br /> FRM-92091: Error fatal inesperado en el código Java de cliente<br /> Java Exception:<br /> java.lang.NullPointerException<br /> t oracle.forms.handler.ComponentItem.doAutoScroll(Unknown Source)<br /> at oracle.forms.handler.ComponentItem.onUpdate(Unknown Source)<br /> at oracle.forms.handler.JavaContainer.onUpdate(Unknown Source)<br /> at oracle.forms.handler.UICommon.onUpdate(Unknown Source)<br /> at oracle.forms.engine.Runform.onUpdateHandler(Unknown Source) ......
Répondre
S
hello i made a log in form when i xecute it display user name and i want that a user cannot execute a query...
Répondre
I
Hello, we are migrating from 6i to 10g. In 6i we use mscomm32.ocx to get information from serial port. Now, in 10g we have to access to port means a java bean. ¿do you have any sample java bean that  can help to us?<br /> Thanks in advance.<br /> Inma
Répondre
O
Inma,This question has nothing in relation with this Bean.You can use the email box to ask general questions (forms.pjc.bean@free.fr)At this moment this site does not have any Java Bean that deal with the serial port.Sun has provided the Java Communications API  you can download here : http://java.sun.com/products/javacomm/Regards,Francois