Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers 10g (10.1.3.1.0) Part Number B25947-01 |
|
|
View PDF |
In addition to creating framework extension classes, you can create custom interfaces that all of your components can implement by default. This section considers an example for an application module, however, the same functionality is possible for a custom extended view object and view row interface as well.
Note: The examples in this section refer to theCustomizedExtensionInterface project in the AdvancedExamples workspace. See the note at the beginning of this chapter for download instructions. |
Assume that you have a CustomApplicationModuleImpl
class that extends ApplicationModuleImpl
and that you want to expose two custom methods like this:
public void doFeatureOne(String arg); public int anotherFeature(String arg);
Perform the following steps to create a custom extension interface CustomApplicationModule
and have your CustomApplicationModuleImpl
class implement it.
Create a custom interface that contains the methods you would like to expose globally on your application module components. For this scenario, that interface would look like this:
package devguide.advanced.customintf.fwkext; /** * NOTE: This does not extend the * ==== oracle.jbo.ApplicationModule interface. */ public interface CustomApplicationModule { public void doFeatureOne(String arg); public int anotherFeature(String arg); }
Notice that the interface does not extend the oracle.jbo.ApplicationModule
interface.
Modify your CustomApplicationModuleImpl
application module framework extension class to implement this new CustomApplicationModule
interface.
package devguide.advanced.customintf.fwkext; import oracle.jbo.server.ApplicationModuleImpl; public class CustomApplicationModuleImpl extends ApplicationModuleImpl implements CustomApplicationModule { public void doFeatureOne(String arg) { System.out.println(arg); } public int anotherFeature(String arg) { return arg == null ? 0 : arg.length(); } }
Rebuild your project.
The ADF wizards will only "see" your interfaces after they have been successfully compiled.
Then, to create a new ProductModule
application module which exposes the global extension interface CustomApplicationModule
and is based on the CustomApplicationModuleImpl
framework extension class, do the following:
Ensure that your application module has a custom Java class.
If it doesn't, you can enable one on the Java page of the Application Module Editor and clicking the Apply button.
Select CustomApplicationModuleImpl
as the base class for the application module.
To do this, again use the Java tab of the Application Module Editor and open the Extends dialog by clicking the Class Extends button.
Indicate that you want the CustomApplicationModule
interface to be one of the custom interfaces that clients can use with your component.
To do this, open the Client Interface page. Click on the Interfaces button. Shuttle the CustomApplicationModule
interface from the Available to the Selected list, then click OK.
Insure that at least one method appears in the Selected list on the Client Interface page.
Note: You need to select at least one method in the Selected list on the Client Interface page, even if it means redundantly selecting one of the methods on the global extension interface. Any method will do in order to get JDeveloper to generate the customProductModule interface. |
When you dismiss the Application Module editor, JDeveloper generates the application module custom interface ProductModule
. It automatically extends both the base ApplicationModule
interface and your CustomApplicationModule
extension interface like this:
package devguide.advanced.customintf.common; import devguide.advanced.customintf.fwkext.CustomApplicationModule; import oracle.jbo.ApplicationModule; // --------------------------------------------------------------------- // --- File generated by Oracle ADF Business Components Design Time. // --------------------------------------------------------------------- public interface ProductModule extends CustomApplicationModule, ApplicationModule { void doSomethingProductRelated(); }
Once you've done this, then client code can cast your ProductModule
application module to a CustomApplicationModule
interface and invoke the generic extension methods it contains in a strongly-typed way.
Note: The basic steps are the same for exposing methods on aViewObjectImpl framework extension class, as well as for a ViewRowImpl extension class. |