Thursday, October 17, 2013

How to implement Select Many Choice feature using ADF Faces, How to use single 'View Object' to display multiple set of list of values using ADF Faces ?



This blog explains about implementing select many choice component as well as capturing the selected values in backing bean.

Scenario : Display two select Many choice components, with different set of list of values by passing bind parameter value to View object dynamically.

Implementation

Step :  Create View object with a bind parameter as shown below,In this example I am using Read only view object with a single bind parameter, and same view object can be used to display multiple select many choice components with different set of values.


Step - Shuffle the Read Only View object to right hand side of Data Model in Application Module as shown below, In this example, I am going to create two instances of same view object, but different bind parameters to each VO instance.

Step - As shown below , Select the View Object instance in right hand side of the data model, Click on 'Edit' button as shown below

Step - Set the corresponding bind parameter value as shown below.


Step -  This his how you see two View object instances available in App Module.


Step - Select the View Object instance in Data Control section, Drag it on to the page as Multi Selection -> Select Many Choice as shown below.

Step - Bind 'Value Change Listener' to backing bean as shown below in order to keep track of selected values


Step - Below is how screen looks like, Try selecting multiple values , you should see selected values in value change listener method.


Thursday, October 10, 2013

How to iterate entities in Application Module Impl class?



Below is the code snippet to iterate through Entities.

       

        // Get EmployeeEO iterator
  Iterator it =EmployeesEOImpl.getDefinitionObject().getAllEntityInstancesIterator(getDBTransaction());
  // Iterate through iterator
        while (it.hasNext()) {
            EmployeesEOImpl eoImpl = (EmployeesEOImpl)it.next();
   System.out.println(eoImpl.getFirstName());

        }
       
 




Wednesday, October 2, 2013

How to Define Nested Application Module In ADF

This blog explains about very cool feature about defining Nested Application Module In ADF

Scenario : I have two different ADF Model projects, Two model projects have two different application modules, and each application module connected to different database. You can nest first application module(eg : CustomerService) to second app module(eg : HistoryDataService), and can access all the capabilities of first application in second application module

Implementation

- In this example, I have two ADF Model projects, First one is CustomerModel and second one is Model project
- I want to nest CustomerServic App Module in 'HistoryDataService' App module part of 'Model' project


- Add the 'CustomerModel' project as dependent on 'Model' project as shown below

- Open Model.jpx file and import 'CustomerModel.jpx' file  as shown below , Click on '+' button to import
- After importing 'CustomerModel.jpx' , Model project will have access to 'CustomerService' App Module


- Open 'HistoryDemoService' Application Module, Expand ' Application Module Instances' section , Shuffle 'CustomerDataService' to right hand side as shown below

- Open 'HistoryDemoService' App module impl class, you will notice 'CustomerService' app module related getter and setter methods as shown below.


How to iterate entities in Application Module Impl class?




If you have a requirement to iterate through each entity object in Application Module Impl, Below is the quick and easiest way to get control of all the entities.

Scenario : Updatable Employee View object based on EmployeesEOImpl dragged onto the screen as <af:table> component, User could delete certain employees from the table, and need to get hold of deleted employee records in Application Module Impl

       

          Iterator it =
            EmployeesEOImpl.getDefinitionObject().getAllEntityInstancesIterator(getDBTransaction());

   while(it.hasnext()){
    EmployeesEOImpl eo = (EmployeesEOImpl)it.next();

            if (eo.getEntityState() == eo.STATUS_MODIFIED) {
                // Do this
            } else if (eo.getEntityState() == eo.STATUS_MODIFIED) {
                // Do this
            } else if (eo.getEntityState() == eo.STATUS_DELETED) {
               // Do this.
            }
}