Dive into BC4J and ADF

Send me a mail
 Dive into BC4J and ADF    Click to see the XML version of this web page.   (Updated: 6/3/2006; 11:50:16 AM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper 10g

Search blog with Google:
 

Search BC4J JavaDoc:
 

November 2003
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
Oct   Dec

Get Firefox!

Wednesday, November 26, 2003

Sure.

All of our components are created through factories. While oracle.jbo.server.EntityImpl is the base framework class for entity objects, its companion factory object is of type oracle.jbo.server.EntityDefImpl. By default, you can use the entity "def" to:

  • Get runtime metadata about the entity object
  • Find any entity instance of that entity type using its primary key via findByPrimaryKey()

You get hold of the def object in one of two ways:

  1. If you generate Java classes for your Entity object's, we generate you a handy getDefinitionObject() static method in the class, so you can call YourEntityObject.getDefinitionObject()
  2. If you don't generate Java classes or prefer to do things in a generic way, then you can call EntityDefImpl.findDefObject("the.fully.qualified.NameOfYourEntity")

The EntityDefImpl also has a createInstance() method on it, but it is intentionally a protected method. This allows the developer of each entity object to decide how to allow instance creation. To allow external classes (for example, like your application module impl class) to instantiate the entity object, you need to provide a custom Entity Definition Class.  You do this by ticking the checkbox on the "Java" panel of the Entity Object editor next to the "Entity Definition Class". In your custom Entity Definition Class, for example EmployeeDefImpl.java, you can decide which public static methods to make available to allow entity instantiation by others.

One choice is to simply override createInstance() and make it public. Another is to create your own custom create method which accepts certain required parameters in order to instantiate your entity (leaving the base createInstance method non-public).

To use your custom entity definition's instance creation methods, just cast the EntityDefImpl instance that you got through one of the suggested methods above to your EmployeeDefImpl class, and call the methods.


11:21:47 PM    



© Copyright 2006 Steve Muench.