Oracle ADF & JDeveloper

Setting security credentials in Application Module test cases

With code like

   ...
   import oracle.jbo.client.Configuration;
   import oracle.jbo.ApplicationModule;
   ...
   String amDef = "model.AppModule";
   String config = "AppModuleLocal";
   ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
   ...

it is possible to instantiate an ApplicationModule in a standalone Java application (means, without the need to launch an application server and deploy the application). Based on the created ApplicationModule instance, the View Objects and View Links defined in the Application Module’s data model can be accessed and test cases for the common CRUD operations (Create, Read, Update, Delete) can be implemented against them. Executing (and debugging) these test cases is very simple since they can be launched as a standalone Java application. However, when the application is configured with ADF security, the following error might occur when executing the above code, and creation of the ApplicationModule fails:

javax.security.auth.login.LoginException: Null or empty password was provided.

In order to solve this, we need to provide login credentials to the application module. They can be configured in the application module configuration:

  • Open the application module’s xml file
  • Select the “Configurations” Tab
  • Select the configuration which is used when creating the application module
  • Click the “Edit” icon to open the Configuration Editor
  • Select the “Properties” tab
  • Set the properties java.naming.security.principal to a valid user name and java.naming.security.credentials to the user’s password

 

Note: You should use a separate user for the test cases, and make sure that this user is not automatically deployed to any production environment!

Oracle ADF: Application Menu meta data wiring

Using the af:navigationPane and af:commandNavigationItem components, it is possible to create menus on a JSF page based on meta data. Setting up the necessary files and declarations for the menu meta data is quite simple: in JDeveloper, select a .jspx file in the project navigator and choose “Create Applications Menu” from the context menu. JDeveloper will take care of creating the necessary meta data entries. See Creating ADF Menus for Page Navigation for more information.

If something goes wrong, it is good to know how the data is wired in the background. The following diagram shows the structure of the meta data which is involved in application menu creation, and how the various parts are looked up once a browser request for a given view arrives:

  • Once the browser request for a view comes in, ADF loads the corresponding .jspx page to create the JSF component tree.
  • At the location where the menu shall be rendered, the .jspx file contains an af:navigationPane component with an embedded af:commandNavigationItem component.
  • af:navigationPane references a managed bean through its value attribute. This bean is implementing the model for the menu.
  • The managed bean has a property named source which contains the name of the menu meta data file to use.
  • For each itemNode in the menu meta data file, ADF creates an af:commandNavigationItem with the corresponding text and action attributes.

Oracle ADF: Required grants when implementing the UIShell

When implementing the Oracle ADF UIShell, it is crucial to set the necessary grants for the UIShell template and the UIShell task flows imported from the ADF libraries. If these grants are not correctly assigned, the dynamic areas of the UIShell remain empty. If unsure, you can check if the dynamic areas are generally working at all by temporarily disabling ADF security. If they do, but then are again empty after re-enabling security, the grants are not properly set up. To assign the necessary grants, open jazn-data.xml through JDeveloper’s “Application/Secure/Resource Grants” menu and select “Resource Type: Web Page”. Make sure to check “Show web pages imported from ADF libraries” – otherwise, only the pages from the project are shown, but not those which reside within ADF libraries. Assign the anonymous-role to oracle_apps_fnd_applcore_templates_UIShell:

Then, select “Resource Type: Task Flow”, and again make sure that “Show task flows imported from ADF libraries” is checked. Assign the anonymous-role to the MainArea, RegionalArea and TasksList task flows as follows:

Oracle JDeveloper: how to define the default run target

In JDeveloper, an application can be deployed to the internal weblogic server by selecting an entry in the project navigator and choosing “Run” from the context menu. JDeveloper then also prints the target URL through which the application can be accessed to its console. Which file is actually used as the application’s starting point and how the target URL is constructed can be defined in the “Run configuration” of the project (usually the ViewController project). Select the ViewController project, and then from the context menu choose “Project Properties”. In the “Project Properties” dialog, select the “Run/Debug/Profile” section from the tree on the left, and then edit the run configuration. The “Edit Run Configuration” dialog is shown (click to enlarge):

In the “Edit Run Configuration” dialog, there are two sections which define the default run target:
  • “Launch Settings” defines the file to use as the run target. This can for example be an ADF task flow file such as adfc-config.xml for the unbounded task flow or a particular .jspx file. Below is the option “Attempt to Run Active File before Default”: this influences whether JDeveloper shall always use the file provided above, or, when a particular file is currently selected in the project navigator, JDeveloper shall first try to use that file as the run target.
  • In case the default run target is an ADF task flow, there is a second section in the “Edit Run Configurations” dialog which needs to be considered: “Launch Settings => ADF Task flow”. There, the actual task flow to execute by default is defined.