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

Creating, Manipulating, and Destroying Forms Objects

With the exception of modules (and a couple of other objects that do not fit typical Forms behavior), all Forms objects must be created as a child of a parent object of the appropriate type. This is reflected in the public constructors for each Java class, which take a parent object of the appropriate type. Where an object can be a child of more than one type, for example, Triggers, there will be constructor for each parent type.

There are also instances of each constructor which can be used to create a subclassed version of a Forms object, subclassing either from another instance of the same type or from a Property Class. Refer to the JDAPI Javadoc for details.

Example


import oracle.forms.jdapi.*; 
/**
 * Example to illustrate how to build a new Form module.
 * We're also doing some basic subclassing here.
 */

public class BuildFormExample 
{ 
  public static void main(String[] args) 
  { 
    // create a module from scratch 
    FormModule fmd = new FormModule("MODULE_ONE");
    Block blockA = new Block(fmd, "EMP");
    Item itemA = new Item(blockA, "ID");
    Item itemB = new Item(blockA, "NAME");
    Item itemC = new Item(blockA, "LOCATION");

    // Create another block subclassed from the first one
    // BlockB will also inherit items ItemA, ItemB and ItemC
    Block blockB = new Block(fmd, "EMP2", blockA);

    // Create a canvas and place our inherited items on it
    Canvas cnv = new Canvas(fmd, "DISPLAY");
    JdapiIterator items = blockB.getItems();
    while(items.hasNext())
    {
      Item item = (Item)items.next():
      item.setCanvas(cnv);  
      // NB Layout setting (x,y pos etc) omitted
    }
    fmd.save("D:/work/Module_One.fmb");
    fmd.destroy();
    Jdapi.shutdown();
  } 
} 

Comments: It should be obvious that creating Forms objects is straightforward. This is the same subclassing behavior which can be seen in the Form Builder. The second created block (blockB), being subclassed from the first, inherits all of its children; that is, the items, triggers, and so on, which it owns. These become subclassed sub-objects of the second block. In a real situation, the source block would be likely to exist in a different module but the principle remains.

To set the new items onto the canvas we're using one of the specific object iterators.

Note that apart from module objects, all constructors take as a first argument the parent object to which the newly constructed object will belong. These only public constructors for Forms object classes all follow this format, which is why it is not possible to instantiate a Forms object independently of an owning module, as described earlier.