Thursday, July 5, 2012

Multi-Select Dependent Drop-Down Lists

I was recently at a customer's site where I had an interesting requirement so I have decided to blog about it. The requirement was to build a master/detail drop-down list. The challenging part was that they wanted the master drop-down list to be a multi-select drop-down list and the detail drop-down list should populate its details based on the master’s selection.

Since ADF does not support master/detail lists for multiple selections i had to follow a different approach. I used the HR schema, with the Departments table as the master drop-down list and the Employees table as the child detail drop-down list. So i created default business component objects (entities and views) based on the Departments and Employees tables.

The trick here is on the detail view object that will serve as the dependent drop-down list. I have created a string bind variable to pass the selected department Ids as a comma separated string of department ids. As you may know, the View Object SQL Query, if used as such, will interpret the whole comma separated value as a single string and of course the query will fail. So to overcome this issue, i have changed the SQL Query using the regexp_substr regular expression function to split the comma separated string and return them as rows (special thanks to Arun).

Employees.DEPARTMENT_ID in (select regexp_substr(:DeptId,'[^,]+', 1, level) from dual connect by regexp_substr(:DeptId, '[^,]+', 1, level) is not null)

In the Application Module, make sure that you add the Departments view object and Employees view object as separate view objects and not dependent. The master/detail dependence will be implemented in a managed bean.

So, create a page and drag on the page the Departments view as a Select Many Choice component and the Employees view object as a Select One Choice component.Make sure that you set the AutoSubmit attribute of the Departments Select Many Choice component to true and in the PartialTriggers attribute of the Employees Select One Choice you have a reference to the Departments Select Many Choice component so that the employees can listen for changes in the departments component.

Go to  the page bindings and create an action binding to the ExecuteWithParams operation of the Employees view object.Your page definition should resemble as below.

The last thing that needs to be done is get the selected department ids, construct a comma separated list of department ids, pass it to the DeptId bind variable of the Employees view and execute the query so that the Employees Select One Choice component gets populated with all employees that belong to all the above selected departments. To do so, edit the ValueChangeListener of the Department Select Many Choice Component and add the following java code to the exposed value change listener method.

public void onDepartmentChange(ValueChangeEvent valueChangeEvent) {
    BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();

    BindingContext bctx = BindingContext.getCurrent();
    BindingContainer bindings = bctx.getCurrentBindingsEntry();
    DCIteratorBinding departmentIterator = (DCIteratorBinding)bindings.get("DepartmentsVOIterator");

    String deptId = null;
    // retrieve selected departments
    if (this.getDepartmentId().getValue() != null) {
        try {
            Integer[] departmentIds = (Integer[])this.getDepartmentId().getValue();

            if (departmentIds.length != 0) {
                for (int x = 0; x < departmentIds.length; x++) {
                    int departmentId = departmentIds[x];
                    Row department = departmentIterator.getRowAtRangeIndex(departmentId);
                    System.out.println("Department Id Index: " + departmentId + " - Department Id: " +
                    if (x == 0) {
                        deptId = ((Number)department.getAttribute("DepartmentId")).toString();
                    } else {
                        deptId =
                                deptId + "," + (String)((Number)department.getAttribute("DepartmentId")).toString();
        } catch (ClassCastException e) {

    OperationBinding queryEmps = bc.getOperationBinding("ExecuteWithParams");
    Map queryEmpsMap = queryEmps.getParamsMap();
    queryEmpsMap.put("DeptId", deptId);

As you can see, all employees belonging to the selected departments (Administration, Shipping and IT) are populated in the employees Select One component.

Download Sample Application - MultiSelectDependentComboBox

Friday, June 22, 2012

Virtual Developer Day: Oracle Fusion Development

Oracle is offering another FREE virtual event where you have the opportunity to learn the latest in Fusion Development, including:
  • Is Oracle ADF development faster and simpler than Forms, Apex or .NET?
  • Mobile Application Development with ADF Mobile
  • Oracle ADF development with Eclipse
  • Oracle WebCenter Portal and ADF Development
  • Building Process Centric Applications with ADF and BPM
  • Oracle Business Intelligence and ADF Integration
  • Live Q&A chats with Oracle technical staff 
 Don't miss this opportunity. Register now!

Tuesday, May 29, 2012

Oracle Weblogic Server 12c Specialization

Be one of the very first to become an Oracle Weblogic Server 12c Certified Implementation Specialist!

The specialization includes the following topics:WebLogic Server 12c functionality, implementation, patching & upgrading as well as Java EE 6, JRockit, HotSpot, Coherence, Virtual Assembly Builder, and Enterprise Manager integration.

For more information, please visit the Oracle Weblogic Server Knowledge Zone and go to the Oracle Weblogic Server 12c Specialization Criteria.

Friday, March 9, 2012

New ADF Book - Oracle JDeveloper 11gR2 Cookbook

Packt Publishing has published a new ADF book written by Nick Haralabidis, Oracle JDeveloper 11gR2.

I've run a quick scan and the book contains some very nice tips and tricks on advanced ADF tasks. This book is not aimed at ADF beginners though.

The book contains over 85 simple, yet effective recipes for using Oracle JDeveloper 11gR2 to build ADF applications. It is well structured, guiding the developer from project setup, to entity objects, view object techniques, LOVs and view criteria, AMs, task flows, backing beans, security, deployment, debugging and fine tuning and monitoring.

In conclusion, i would highly recommend this book to any ADF developer.

Friday, February 17, 2012

Oracle WebCenter 11g and ConcurrentModificationException

I came accross recently a very weird issue on Oracle WebCenter 11g PS4 (

I had a page, with four portlets. One of them had a portlet parameter. When I tried to provide a value for that portlet parameter at runtime (using the WebCenter Administrator), i got a ConcurrentModificationException exception. Here is a snippet from the log file:

at java.util.LinkedList$ListItr.checkForComodification(
at java.util.LinkedList$
at oracle.portlet.client.containerimpl.event.EventManagerImpl.fireEvent(

After loggin an SR, this is a known issue and Oracle has a fix for it (patch 10427778).

Wednesday, February 1, 2012

Ensuring that your ADF Application is Passivation/Activation Safe

Hi everyone,

Just a quick note on passivation/activation. ADF works with two pools, Application (via AMs) and Database (via your database connection). Each time a user accesses a resource and that resource uses an AM to display data, the Application Module pool manager assigns an AM instance to the user session. If the pool runs out of connections, the AM pool Manager passivates the state of one of the sessions (either in the database or in a file), thus releasing an instance and assigning it to the new session. When the user that was passivated resumes their work, ADF will activate their state from the configured store. This is done automatically for you for all attributes that are mapped to a database column.

However, for transient attributes and transient views, if you do not mark them to be passivated, their state will be lost, and during activation will be empty. You can test if your ADF application is passivation/activation safe by deselecting the “Enable Application Module Pooling” option in the “Pooling and Scalability” tab of the AM configurations. This will basically force the framework to passivate/activate your session state with every click that you perform.

***NOTE*** Do not forget to enable AM pooling once you have tested your application.

To mark a transient attribute that is part of a normal view to be passivated, you just need to select the “Passivate” attribute on a the view object attribute.

In the case of a transient view (programmatic) though, you need to do a couple of things:

a) Mark the whole view, including all transient attributes to be passivated
b) Make sure that the “No Rows” option is selected in the “Retrieve from the Database” section is selected
c) Override the beforeRollback and afterRollback methods in the ViewObjImpl class by commenting out the call to super.

Friday, January 27, 2012

Oracle Fusion Middleware in a Real Life Example

This is a video that I have prepared for one of my clients some time ago to demonstrate how Oracle Fusion Middleware can be used to satisfy their business requirements.

The client, a global provider of marine transportation services, wanted to automate the communication process between their vessels and headquarters. The implementation approach had to take into account three major requirements; to minimize the network traffic between vessels and headquarters as much as possible as ships are using satellite connection to establish connection with headquarters which is very expensive, to automate the backend workflow and approval process and to provide a solution that wouldn’t require any installation to take place on the vessels.

The purpose of this video is not to provide step-by-step instructions on how to implement such a solution but to give you a broad overview of the capabilities and features of several Oracle Fusion Middleware products and technologies, such as Weblogic 10.3.2 as the Application Server, SOA 11g consisting of BPEL for designing our business processes and BAM for monitoring  the business services using interactive real-time dashboard reports, Oracle Business Intelligence 11g as the reporting solution for generating dynamic reports, Oracle Universal Content Server 10g for managing and filling all documents generated, Oracle Internet Directory 11g as the LDAP directory service and Oracle Database 11g as the persistence store.

Thursday, January 12, 2012

Fusion Middleware Partner Community Forum - Feb 7th and 8th 2012 Malaga, Spain

Oracle, for the first time, organizes a combined Fusion Middleware Partner Community Forum in Malaga Spain for the SOA & WebCenter & BPM & WebLogic Partner Communities.

The event will take place on February 7th and 8th 2011 at the NH Hotel in Malaga, Spain. It will be followed by a two-days hands-on training workshops on ADF & WebCenter, WebLogic 12c and SOA.

You can register by clicking here.

See you all in Malaga!