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

Traversing Object Libraries

Just like a Form Module, an object library can be programmatically traversed either generically or using specific accessors. The great advantage here is that you can write code to process any module generically, without worrying about what type of module it is.

Unlike the C API, the Object Library contents are presented hierarchically by tab, so it's easier to iterate through the library tab by tab. Of course, it is also possible to traverse the Object Library generically as in the example in Writing Generic Code Using Metadata.

Example

The following code sample illustrates how an object library's object tree can be traversed.

  
import oracle.forms.jdapi.*; 
/**
 * Example showing how to explicitly traverse an object library's object tree
 */
public class TraverseObjLibExample 
{ 
  public static void main(String[] args) 
  {
    // first dump the object names tab by tab
    ObjectLibrary olb = ObjectLibrary.open("myolb.olb");

    JdapiIterator tabs = olb.getObjectLibraryTabs();  
    while(tabs.hasNext())
    {
      ObjectLibraryTab olt = (ObjectLibraryTab)tabs.next();
      JdapiIterator tabObjects = olt.getTabObjects();
      while(tabObjects.hasNext())
      {
        JdapiObject jo = (JdapiObject)tabObjects.next();
        System.out.println(jo.getName());    
      }
    }

    // now dump the object names all in one go
    // the output list should be the same as the previous one 
    // though perhaps in different order
    JdapiIterator libObjects = olb.getObjectLibraryObjects();
    while(libObjects.hasNext())
    {
      JdapiObject jo = (JdapiObject)libObjects.next();
      System.out.println(jo.getName());
    }
    Jdapi.shutdown();
  }
}