Thursday, March 27, 2014

ADF User Preferences

ADF Provides extension to standard Java Preferences API and is maintained in MDS Repository. 

You can reference following Javadoc and Blog:
But this does not work in Plain ADF application and you will run into following exception.
oracle.mds.exception.ReadOnlyStoreException: MDS-01273: The operation on the resource /oracle/adf/share/prefs/data/preferences.xml failed because source metadata store mapped to the namespace / DEFAULT is read only.
To resolve this issue, change your application's adf-config.xml file as highlighted below.

<persistence-config>
       <metadata-namespaces>
          <namespace path="/oracle/adf/share/prefs" metadata-store-usage="MAR_TargetRepos"/>
          <namespace path="/persdef" metadata-store-usage="MAR_TargetRepos"/>
       </metadata-namespaces>
       <metadata-store-usages>
          <metadata-store-usage id="MAR_TargetRepos" deploy-target="true" default-cust-store="true">
          </metadata-store-usage>
       </metadata-store-usages>
</persistence-config>

Wednesday, March 19, 2014

Using Transient Attribute on Business Components

This is very simple task, but could be useful for developers who are new to ADF. You can add a Transient attribute that is derived from other attributes or from some other data source. Here are simple steps on how to do this and how to make sure that value for Transient Attribute gets updated when other attributes are changed.

  • Create new attribute on Entity object.



  • It seems attribute is marked as persistent. So you will have to change it.



  • If you don't have Entity Java class and accessor methods, please generate it (see Java tab). Once you have get method for FullName, change as shown below.


  • Add same attribute to your View Object as well, so that you can run BC Tester.


  • As you navigate to rows, you will data change in FullName. But if you change FirstName of LastName, it is not reflected in FullName. You will need to specify Dependency on FirstName and LastName for FullName attribute as shown in next screenshot.



  •  Now as you change FirstName, you will see change in FullName immediately.

These same steps apply to View Object transient attributes also, except few minor differences.

Saturday, March 15, 2014

Creating Transient View Object

Transient View Objects are very useful to build data entry forms when you don't necessarily want to create instances of Entity based View Objects till later time. In my projects, i have always tried to use Transient View Objects instead of POJO Databeans to bind to UI components. I have also used such Transient View Objects to collect search terms, when not using Query component, then i create and apply View Criteria in my Application Module method based on data entered by User which is collected from Transient View object.

Here is how you can create  Transient View Object.
  • Create New View Object, make sure to create View object in default views package. We will re-factor into different package later. This is done as JDeveloper at times creates Java files in wrong package otherwise.
  • Use consistent suffix for View Object Name to indicate that it is Transient View Object.
  • Select Programmatic option for Data Source in View Object wizard.
  • Add attributes as needed.
  • Make sure all Attributes are always updatable and set to be persisted. Also, Make sure to define a Primary Key attribute (one or more) for View object.

  • Finish View Object creation wizard.
  • Go to general tab, expand Tuning and Make sure No Rows is selected for Retrieve from the Database section.
  • Save your work.
  • Refactor Transient View Object in to a different package of your choice. For example, views.trans package.
  • Open View Object's Java file, generate if you don't have it and implement beforeRollback and afterRollback methods as shown below.