Thursday, December 26, 2013

How to make case Insensitive with top line filter values

This blog explains about case insensitive with <af:table> top line filter.

Scenario : Should ignore the Upper/Lower case with <af:table> top line filter values.

Resolution : set 'filterFeatures' property value to 'caseInsensitive'


Tuesday, December 24, 2013

How to get Selected Value of SelectOneChoice rather than in Index value in ADF


By default always <af:selectOneChoice> - ValueChangeListener() method gives the index rather than selected value.

Scenario : Get the selected short code of <af:selectOneChoice> component rather than getting index value in valueChangeListener() method binds to <af:selectOneChoice> component

Resolution
- Define ValueChangeListener for the <af:selectOneChoice> component as shown below


Perform below logic





How to invoke Backing Bean method and display popup simultaneously in ADF ?


This blog explains about invoking a backing bean method before displaying <af:popup>


Step1 - Define <af:popup> as shown below, Bind the popup to backing bean , I strongly recommend rather than binding to backing bean, Find the UI Component


Step2 - Bind to backing bean method as shown below


Step3 : Invoke the functionality whatever needed, then get the instance of the popup and invoke show() method as shown below.

How to display data bottom of each column in component using ADF


Scenario : To display sum of data in a specific column at the bottom table component , For eg : Display sum of salaries of all the employees in <af:table> component, corresponding to 'Salary' column in <af:table> component

Resolution :

Include <f:facet name="footer">Determine Sum of salaries </f:facet> in <af:column> component.

How to Hide Popup Progrmatically In ADF

This blog explains about how to hide a <af:popup> programatically ?

Resolution : Bind Popup Component to Managed Bean, Whenever you want to close the popup based on some condition ,  Get the instance of popup binding and invoke hide() operation.


    public void closeCreatePopup() {
        createPopupBinding.hide(); // createPopupBinding is popup binding
    }

java.sql.SQLSyntaxErrorException: ORA-01722: invalid number

This blog explains the root cause for ORA-01722 and steps need to be taken to resolve this issue.

Reason :  If you are trying to set a bind parameter value i.e String and comparing against  Numeric value you will see this error . For eg : You have empID = :BindEmpID , If you pass the :BindEmpID value as 'XYZ' then it will throw 'Invalid Number' exception because empID in database table is number field.

How to Resolve - Ensure always pass numeric values to bind paramenter when the corresponding bind parameter compares against numeric value

'Flex' Property in ADF , How to distribute uniform space between buttons in ADF


If you want to equally distribute the space b/w buttons , set 'flex' property as shown below, This will set uniform space b/w each button on toolbar container. Also adjust the width of the toolbar, So that it will display all the buttons always.

  <af:toolbar id="t2" flex="1">

java.util.MissingResourceException:Can't find bundle for base name


If you notice below exception when you deploy ADF application to any stand alone weblogic server, follow below steps to resolve.

Caused By: java.util.MissingResourceException: Can't find bundle for base name yourresourcebundlelocation, locale en_US
     at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1427)
     at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1250)
     at java.util.ResourceBundle.getBundle(ResourceBundle.java:705)
     at Searchusr.SearchModuleImpl.<clinit>(SearchModuleImpl.java:53)
     at java.lang.Class.forName0(Native Method)
     Truncated. see log file for complete stacktrace
>

Step1 : Ensure you specify complete path of your resource bundle name in all the pages.
Step2 : Specify the complete path in faces-config.xml as shown below

Step3 : Ensure specify complete path in UI Project Properties as shown below.

Tuesday, December 3, 2013

Most commonly used SQL commands

ALTER TABLE EMPLOYEES ADD AUDIT_ID NUMBER NOT NULL

ALTER TABLE EMPLOYEES DROP COLUMN AUDIT_ID NUMBER NOT NULL


- This query converts the 'String' Date Time object to date object and stores into database, Explains about using to_date() function.

INSERT INTO AUDIT(AUDIT_ID,ENTITY_NAME,AUDIT_KEY,ENTITY_ID,OPERATION,CREATED_BY,CREATION_DATE,LAST_UPDATED_BY,LAST_UPDATE_LOGIN,LAST_UPDATE_DATE) VALUES(23,'HEADERS','AGREEMENT_HEADER_ID','283','INSERT','admin',to_date('20090202121212','yyyyMMddHH24MISS'),'admin','admin',to_date('20090202121212','yyyyMMddHH24MISS'))

// Create DB Sequence

CREATE SEQUENCE  "HR"."EMPLOYEE_ID_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 61 CACHE 20 NOORDER  NOCYCLE ;

// Test DB Sequence using SQL Worksheet
select EMPLOYEE_ID_SEQ.nextval from dual

// Get first n Rows from the Database

SELECT * FROM EMPLOYEES WHERE ROWNUM <=5

// Alter the database table column
ALTER TABLE EMPLOYEE MODIFY SALARY NUMBER;

// Left Outer Join

The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match.

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;

Monday, December 2, 2013

SQL Functions to perform IN() clause using ADF Business Components


This blog explains about performing IN() clause with comma separated values in ADF Business components.

Scenario 1 : Get all the employees where employee first name in ('Bob','Rob','Peter','Dan'), Using ADF Business components, pass the comma separated values as a bind parameter and execute the query using the SQL function which I am going to outline in below.

Scenario2 : Same as above, instead of String, 'Number' data type

FM_GN_IN_NUMBER_LIST  - This function accepts comma separated Numbers, delimit the String by ',' and returns array of numbers. So that we can avoid writing query to de


Function 1

// Create num_table type
CREATE TYPE num_table AS TABLE OF NUMBER;

create or replace
FUNCTION     FM_GN_IN_NUMBER_LIST (p_in_list  IN  VARCHAR2)
RETURN num_table
AS
l_tab   num_table := num_table();
l_text  VARCHAR2(32767) := p_in_list || ',';
l_idx   NUMBER;
BEGIN
LOOP
l_idx := INSTR(l_text, ',');
EXIT WHEN NVL(l_idx, 0) = 0;
l_tab.extend;
l_tab(l_tab.last) := to_number(TRIM(SUBSTR(l_text, 1, l_idx - 1)));
l_text := SUBSTR(l_text, l_idx + 1);
END LOOP;

RETURN l_tab;
END;

Function2:

//Create table_of_varchar type as shown below

CREATE TYPE table_of_varchar AS TABLE OF VARCHAR2(2300);

create or replace
FUNCTION     FM_GN_IN_STRING_LIST (p_in_list  IN  VARCHAR2)
RETURN table_of_varchar
AS
l_tab   table_of_varchar := table_of_varchar();
l_text  VARCHAR2(32767) := p_in_list || ',';
l_idx   NUMBER;
BEGIN
LOOP
l_idx := INSTR(l_text, ',');
EXIT WHEN NVL(l_idx, 0) = 0;
l_tab.extend;
l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
l_text := SUBSTR(l_text, l_idx + 1);
END LOOP;
RETURN l_tab;
END;

Usage: Below is the example, how to call the function

EmployeeEO.EMP_ID IN (SELECT * FROM TABLE(CAST(fm.fm_gn_in_string_list(:BineEmpID) AS fm.table_of_varchar)))

Thursday, November 21, 2013

How to invoke Stored Procedure from a package, Convert the response to POJO using Java

This blog explains about invoking a stored procedure from a package and convert the stored procedure response back to POJO(Plain Old Java Object) using Java

- Below is the Java class, which connects to database, execute stored procedure from a package, Convert the response to List of POJO's
       

      /**
     * Invoke Stored Procedure from a package
     * Iterate the result from Stored Procedure, populate the response to
     * Employee POJO class.
     * @param eName
     * @return
     * @throws Exception
     */
    public static List getEmployees(String eName) throws Exception {
        List empList = new ArrayList();
        Connection dbConnection = null;
        CallableStatement callableStatement = null;
        ResultSet rs = null;
        String empSql = "{call employee_pkg.getEmployees(?,?)}";
        try {
            dbConnection = getDBConnection();
            callableStatement = dbConnection.prepareCall(empSql);
            callableStatement.setString(1, eName);
            callableStatement.registerOutParameter(2, OracleTypes.CURSOR);
            callableStatement.executeUpdate();
            rs = (ResultSet)callableStatement.getObject(2);
            while (rs.next()) {
                Employee emp = new Employee();
                emp.setEmpNo(rs.getInt("empno"));
                emp.setEmpName(rs.getString("empname"));
                emp.setEmpSal(rs.getInt("sal"));
                empList.add(emp);
            }
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        } finally {
            if (rs != null) {
                rs.close();
            }
            if (callableStatement != null) {
                callableStatement.close();
            }
            if (dbConnection != null) {
                dbConnection.close();
            }
        }
        return empList;
    }
       
 
- Here is Employee POJO class
       

  public class Employee 
{
 private int empNo;
 private String empName;
 private int empSal;
 
 public int getEmpNo() 
 {
  return empNo;
 }
 public void setEmpNo(int empNo) 
 {
  this.empNo = empNo;
 }
 public String getEmpName() 
 {
  return empName;
 }
 public void setEmpName(String empName) 
 {
  this.empName = empName;
 }
 public int getEmpSal() 
 {
  return empSal;
 }
 public void setEmpSal(int empSal) 
 {
  this.empSal = empSal;
 }
}


       
 

- Here is sample Stored Procedure
       

  
CREATE OR REPLACE PACKAGE employee_pkg AS
  TYPE employee_cur IS REF CURSOR RETURN employees%rowtype;
  PROCEDURE getEmployees (ename IN VARCHAR2, empData OUT employee_cur);
END employee_pkg;
/

CREATE OR REPLACE PACKAGE BODY employee_pkg AS 
  PROCEDURE getEmployees (ename IN VARCHAR2, empData OUT employee_cur) AS
  BEGIN
    OPEN empData FOR
 SELECT empno, empname, sal FROM employees WHERE empname = ename ORDER BY empno;
  END getEmployees;  
END employee_pkg;
/
       
 

Tuesday, November 12, 2013

How to Create Popup Using ADF

This blog explains about creating a simple popup using ADF

Scenario : Display a popup by clicking on button

Implementation

 - Drag the 'popup' component from component pallet to page/page fragment
 - Drag the 'dialog' component from the component pallet to page/page fragment
 - You can define whatever components you want on this dialog, Even you can drag the taskflow as a region on it.
- Below is how source code looks like



- Drag the 'ShowPopupBehavior' component from the component pallet on to 'button'
- Define the popupId attribute, In this example, popup ID value is 'p1' as per above screen shot.

- Run the page, you will see the button as shown below

- Click on the button, below is the screenshot for popup window how it displayed



Below section explains, about how you can invoke popup programatically based on some condition

// Below is the code to get the RichPopup component in backing bean

            RichPopup popup =
                (RichPopup)JSFUtils.findComponent("p1");
            if (popup != null) {
                  // Hid the popup
                  popup.hide();
            }

             // Here is the code to show popup.
             popup.show(new RichPopup.PopupHints());

// Define <af:outputText> in <af:dialog> and bind the value of this property to backing bean, and set whatever message you want to display based on some specific condition in backing bean.

Also, You can bind the 'title' attribute of <af:dialog> component to backing bean , Get the dialog component using findComponent() method and set whatever the title you want to display.

popupFetchListener : Bind this attribute to any backing bean method in order to invoke any functionality while loading the popup

dialoglistener : This attribute belongs to <af:dialog> component, Bind this attribute to any backing bean method , in order to execute code upon any action(Ok, Cancel, Yes, No, etcc)  performed on a popup

 public void doCancel(DialogEvent dialogEvent) {
        Outcome outcome = dialogEvent.getOutcome();
        if (Outcome.yes == outcome) {
            
        }
    }

How to programatically hide and show the popup in ADF ?

 - Get the Popup UI component instance i.e RichPopup
 - empPopup.show(new RichPopup.PopupHints());
- To Hide : empPopup.hide()


Refer below blog for findComponent() implementation


- You can customize the popup the way you want, mouse hover, value change, on focus, etc..

Here is more documentation about popup

http://docs.oracle.com/cd/E21764_01/apirefs.1111/e12419/tagdoc/af_showPopupBehavior.html

http://docs.oracle.com/cd/E17904_01/apirefs.1111/e12419/tagdoc/af_popup.html

ADF Naming Standards and Best Practices

Naming Standards are very important to organize the code, especially when you are working with large scale applications. Below are the naming conventions based on JUST my past experience


Business Components

  Entity                                  - Suffix with 'EO' - example : EmployeeEO
  Updateable View Object      - Suffix with 'VO' - example : EmployeeVO
  Programmatic View Object  - Suffix with 'TRVO' example : EmployeeTRVO
  ReadOnly View Object        -  Suffix with 'ROVO' example : EmployeeROVO
  List of Values View Object  -  Suffix with 'LOV' example : GenderLOV
  View Link                            - Suffix with 'VL' example : EmployeeDepartmentVL
   Association                         - Suffix with 'Assoc' Example : EmployeeDepartmentAssoc
  View Accessor                    - Suffix with 'VA' Example :  EmployeeNameVA
  Application Module               - Suffix with 'Service' example : EmployeeService

Packaging

Entities                            :     com.<application>.<project>.model.entities
Updateable View Object :     com.<application>.<project>.model.queries    
Application Module         :      com.<application>.<project>.model.services           
Programmatic View Object :     com.<application>.<project>.model.trvo
View Link                          :    com.<application>.<project>.model.vl
Association                        :    com.<application>.<project>.model.assoc
Read only View Object      :    com.<application>.<project>.model.readonly

Application Naming 
- Giver proper name to application , For eg : EmployeeMgmt, CustomerMgmt, VendorMgmt, etc.. The name of the application should be meaningful with respect to the functionality

Project Naming
 - Give meaningful name to each project you create in any application
 - Model Project :
   Example : EmployeeModel, CustomerModel,VendorModel - All the model projects suffix with 'Model'
- View Controller Project : 
 Example : EmployeeUI, CustomerUI, VendorUI - This project holds all the User Interface related components such as .jsff, jspx, xml, etc..

- Web Service Projects
 Example : EmployeeWSService, CustomerWSService, VendorWSService - All these projects contains the web services related.

- Web Service Proxies
Example : EmployeeWSProxies, VendorWSProxies, CustomerWSProxies - All these projects contains the web service proxy related files.

- JSP Pages

Example : create-employee.jspx, edit-employee-job-details.jspx - Give meaningful name, all lower case , better if seperated by '-'

- Page Fragments (.jsff)
Same as JSP Pages

- Task Flow
- Meaningful name separated by '-' and prefix with config.xml
   Ex : create-employee-config.xml , edit-employee-job-details-config.xml

Backing Bean

- Give meaningful name such as 'EmployeeBean', 'CustomerBean', 'VendorBean' etc.
- Package : com.fm.helloworld.view.backing.EmployeeBean
- Every bean class must implement java.io.Serializable interface.
- Try to avoid binding any ADF UI components to Backing beans

Best Practices
- Define entry and exit log messages as shown below

import java.util.logging.Level;
import java.util.logging.Logger;

// Define below at class level

private static final String CLAZZ_NAME = EmpServiceImpl.class.getName();
private static final Logger _logger = Logger.getLogger(CLAZZ_NAME);

 public void runPublication()
  {
    String methodName = "runPublication()";
    _logger.entering(CLAZZ_NAME, methodName);
    _logger.exiting(CLAZZ_NAME, methodName);
  }
// Log Exceptions as below
      _logger.logp(Level.FINEST, CLAZZ_NAME, methodName,

                   message.toString(), pException);
// Log Information messages as below
              _logger.logp(Level.FINEST, CLAZZ_NAME, lMethodName,
                           " Invoking  updateRates() CORBA Call: Data List Size " +
                           newDataList.size());
Follow this link for better performance tips and best practices : http://fortunefusionminds.blogspot.com/2011/12/performance-tuning-tips-with-adf-web.html


  

Wednesday, November 6, 2013

How to ignore unwanted files using Tortoise GIT tool


create .gitignore file in your root directory and include required unwated entires there.

For eg : I want to ignore all the class files in Model project

/EmployeeManagement/EmpModel/classes
*.obj
*.class

This will exclude displaying these files before you check-in.

Tuesday, November 5, 2013

How to Configure Data Source in Weblogic Console


This blog explains about creating a data source in Web logic console. ADF Applications can use this data source reference in Application Module configurations, and when the application deployed to Web logic console, ADF application will connect to database using the Data source which is defined in Web Logic Console

Implementation

 - Ensure, Weblogic server is up and running , Login to Weblogic Console, Choose Services as shown below, Click on 'Data Sources'

- Choose New -> Generic Data Source as shown below.

- Enter valid name and JNDI Name as shown below

- Choose the Database driver based on the database which you are going to connect.

- Enter the valid values for Database name, Host Name, Port , User Name and Password as shown below

- Choose Next, then verify all the details, Test the DB details by clicking on 'Test Conifguration' button as shown below.

- Finally choose the targets where you want to use the data source.

- You have successfully conrigured data source.

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.
            }
}
       
 




Monday, September 30, 2013

How to get only modified attributes in an Entity ?

This blog explains about performing customized audit s on a specific tables

Scenario : Audit only modified columns associated data into Audit table, rather than unmodified field values into history/audit table.

 - get only modified attribute name, old value and new value for an entity
 - get the table name associated to an entity
 - get the database column name associated to an entity
- store only modified columns associated data into audit table.

Implementation

- Create a BaseEntityImpl class which extends to oracle.jbo.server.EntityImpl, override doDML() method as shown below

- Get the entity state, based on the entity state perform database CRUD operations.


       

           @Override
    protected void doDML(int i, TransactionEvent transactionEvent) {
        String userName =
            ADFContext.getCurrent().getSecurityContext().getUserName();
        SimpleDateFormat sdf = new SimpleDateFormat("d-MMM-yyyy HH:mm:ss");
        String currentTime = sdf.format(System.currentTimeMillis());

        if (EntityImpl.DML_DELETE == i) {
            System.out.println("Delete operation");
            Long timeInMillis = System.currentTimeMillis();
            try {

                String sql =
                    "INSERT INTO XXATDTPR_HISTORY_DATA(ID,TABLE_NAME,KEY_NAME,KEY_VALUE,OPERATION,CREATED_BY,CREATED_ON,UPDATED_BY,UPDATED_ON) VALUES(" +
                    timeInMillis + ",'" + this.getEntityDef().getSource() +
                    "','" +
                    ((BaseDefImpl)this.getEntityDef()).getPrimaryKeys()[0].getColumnName() +
                    "','" +
                    getAttribute(((BaseDefImpl)this.getEntityDef()).getPrimaryKeys()[0].getIndex()) +
                    "','" + "DELETE" + "','" + userName + "','" + currentTime +
                    "','" + userName + "','" + userName + "')";
                System.out.println("SQL :: " + sql);
                getDBTransaction().executeCommand(sql);

            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (EntityImpl.DML_INSERT == i) {
            System.out.println("Insert operation");

            Long timeInMillis = System.currentTimeMillis();
            try {

                String sql =
                    "INSERT INTO XXATDTPR_HISTORY_DATA(ID,TABLE_NAME,KEY_NAME,KEY_VALUE,OPERATION,CREATED_BY,CREATED_ON,UPDATED_BY,UPDATED_ON) VALUES(" +
                    timeInMillis + ",'" + this.getEntityDef().getSource() +
                    "','" +
                    ((BaseDefImpl)this.getEntityDef()).getPrimaryKeys()[0].getColumnName() +
                    "','" +
                    getAttribute(((BaseDefImpl)this.getEntityDef()).getPrimaryKeys()[0].getIndex()) +
                    "','" + "INSERT" + "','" + userName + "','" + currentTime +
                    "','" + userName + "','" + userName + "')";
                System.out.println("SQL :: " + sql);
                getDBTransaction().executeCommand(sql);

            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (EntityImpl.DML_UPDATE == i) {
            System.out.println("Update operation");

            AttributeDef[] attributeDefs =
                this.getEntityDef().getAttributeDefs();
            for (AttributeDef attributeDef : attributeDefs) {
                if (isAttributeChanged(attributeDef.getIndex())) {
                    Object oldValue =
                        getPostedAttribute(attributeDef.getIndex());
                    Object newValue = getAttribute(attributeDef.getIndex());
                    //use sequence generator here to generate unique prmary key
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                    }

                    Long timeInMillis = System.currentTimeMillis();
                    try {

                        String sql =
                            "INSERT INTO XXATDTPR_HISTORY_DATA(ID,TABLE_NAME,KEY_NAME,KEY_VALUE,COLUMN_NAME,OLD_VALUE,NEW_VALUE,OPERATION,CREATED_BY,CREATED_ON,UPDATED_BY,UPDATED_ON) VALUES(" +
                            timeInMillis + ",'" +
                            this.getEntityDef().getSource() + "','" +
                            ((BaseDefImpl)this.getEntityDef()).getPrimaryKeys()[0].getColumnName() +
                            "','" +
                            getAttribute(((BaseDefImpl)this.getEntityDef()).getPrimaryKeys()[0].getIndex()) +
                            "','" + attributeDef.getName() + "','" +
                            oldValue.toString() + "','" + newValue.toString() +
                            "','" + "UPDATE" + "','" + userName + "','" +
                            currentTime + "','" + userName + "','" + userName +
                            "')";
                        System.out.println("SQL :: " + sql);
                        getDBTransaction().executeCommand(sql);

                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        super.doDML(i, transactionEvent);
    }
       
 




Thursday, September 26, 2013

Various Entity States in ADF


Below are the list of various entity states, which are helpful to determine whether entity has been updated or not.

Below is how we can determine the state of an entity.
 VORowImpl newRow = (VORowImpl )getVO1().getCurrentRow();
        EOImpl eo = (EOImpl) newRow.getEntity(0);
        byte newRowStatus = eo.getEntityState();
        if (newRowStatus ==  eo.STATUS_NEW){
            isNewRow = true;
        }

States are set to one of these values: STATUS_INITIALIZEDSTATUS_NEWSTATUS_MODIFIEDSTATUS_DELETED and STATUS_DEAD based on whether the Entity Object is being created, updated, deleted, or rolled back, respectively. These operations can set either or both the post-state and the Entity-state. The status values have a slightly different meaning depending on whether they are set for an Entity-state or a post-state:
  • For Entity-state:
    • STATUS_UNMODIFIED - if this Entity Object originated in the database and is unmodified, or if modifications have been committed to the database.
    • STATUS_MODIFIED - if this Entity Object originated in the database, and has been modified in the current transaction.
    • STATUS_NEW - if this Entity Object is new in the current transaction.
    • STATUS_DELETED - if this Entity Object has been deleted in the current transaction.
    • STATUS_DEAD - if this Entity Object is new in the current transaction and has been deleted.
  • For post-state:
    • STATUS_UNMODIFIED - if this Entity Object has been queried from the database and is unchanged, or if it has been posted to the database.
    • STATUS_MODIFIED - if this Entity Object has been queried from the database and has changed.
    • STATUS_INITIALIZED - if this Entity Object is new and the client application changed it's state to make this Object temporary.
    • STATUS_NEW - if this Entity Object is new in the post-cycle.
    • STATUS_DELETED - if this Entity Object has been marked for deletion.
    • STATUS_DEAD - if this Entity Object is new, but has been deleted.

Where to find system-jazn-data.xml?


System-jazn-data.xml - The system-jazn-data.xml is an XML file which is configured by the user to use as an ID store and/or policy store.This file stores all the roles and permissions for all the custom secured applications which are deployed to stand alone weblogic server. This file will be updated automatically whenever any secured application deployed. This is the master file which contains all the roles/permissions related information.

Where to find this file in UNIX box ?

 The file is located in$DOMAIN_HOME/config/fmwconfig.

Where can I find this file in local machine ?


C:\Users\user\AppData\Roaming\JDeveloper\system11.1.1.6.38.62.29\DefaultDomain\config\fmwconfig

Wednesday, September 25, 2013

How to test PL/SQL Stored Function in JDeveloper



This blog explains about testing Pl/SQL stored procedure using Jdeveloper

- Connect to the corresponding database where your function created.
- Right click on the database connection , Choose SQL Worksheet
- In this example, I have created a stored function named 'get_emp_fullname()' which accepts one parameter i.e called Employee ID and returns Employee Full Name
-  As shown below, use the query to test the function by passing required values for the arguments, you will see the response as shown below



s

J2EE[160149]Error while processing library references. Unresolved application


This blog explains about how to resolve the below error while deploying ADF applications to stand alone Weblogic server

Deployment Error :
<07 Mar 2013 9:17:19 AM> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1362640639128' for task '1'. Error is: 'weblogic.management.DeploymentException: [J2EE:160149]Error while processing library references. Unresolved application library references, defined in weblogic-application.xml: [Extension-Name: oracle.webcenter.framework, Specification-Version: 11.1.1, exact-match: false], [Extension-Name: oracle.webcenter.skin, Specification-Version: 11.1.1, exact-match: false], [Extension-Name: oracle.sdp.client, exact-match: false], [Extension-Name: oracle.soa.workflow.wc, exact-match: false].'
weblogic.management.DeploymentException: [J2EE:160149]Error while processing library references. Unresolved application library references, defined in weblogic-application.xml: [Extension-Name: oracle.webcenter.framework, Specification-Version: 11.1.1, exact-match: false], [Extension-Name: oracle.webcenter.skin, Specification-Version: 11.1.1, exact-match: false], [Extension-Name: oracle.sdp.client, exact-match: false], [Extension-Name: oracle.soa.workflow.wc, exact-match: false].
     at weblogic.application.internal.flow.CheckLibraryReferenceFlow.prepare(CheckLibraryReferenceFlow.java:26)
     at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:613)
     at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
     at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:184)
     at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
     Truncated. see log file for complete stacktrace
>
<07 Mar 2013 9:17:19 AM> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'VulindlelaScreens'.> 
<07 Mar 2013 9:17:19 AM> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.management.DeploymentException: [J2EE:160149]Error while processing library references. Unresolved application library references, defined in weblogic-application.xml: [Extension-Name: oracle.webcenter.framework, Specification-Version: 11.1.1, exact-match: false], [Extension-Name: oracle.webcenter.skin, Specification-Version: 11.1.1, exact-match: false], [Extension-Name: oracle.sdp.client, exact-match: false], [Extension-Name: oracle.soa.workflow.wc, exact-match: false].
     at weblogic.application.internal.flow.CheckLibraryReferenceFlow.prepare(CheckLibraryReferenceFlow.java:26)
     at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:613)
     at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
     at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:184)
     at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
     Truncated. see log file for complete stacktrace
>
[09:17:19 AM] ####  Deployment incomplete.  ####
[09:17:19 AM] Remote deployment failed (oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer)
#### Cannot run application VulindlelaScreens due to error deploying to IntegratedWebLogicServer.
[Application VulindlelaScreens stopped and undeployed from Server Instance IntegratedWebLogicServer]
Resolution

- Click on 'Lock & Edit'
- Login to stand alone weblogic server where you are trying to deploy
- Select Deployments
- Click on 'adf.oracle.domain' library ( Select whatever the library it says missing in deployment error log) in summary of Deployments
- Click on 'Targets'
- Ensure selected library is associated to target server/cluster , If not select the check box corresponding to target cluster/managed server
- Save changes
- Click on 'Activiate Changes'
- You are all set now.




Tuesday, September 17, 2013

How to design layout templates in ADF ?

This blog explains about creating custom layout template and extending this layout in an ADF application.

What is template ?

A template in WebCenter (or an ADF application) is nothing more than a JSPX page with additional tags to define some regions. This means that you can use all the existing ADF or WebCenter components in your template.

This is very very common requirement in most of the ADF applications, It brings unique look and feel through out the application. In this example, I will be designing a template with two sections header and body. Header section contains company logo, title and logged in user info, Whereas body section holds the place holder for implementing pages to supply the necessary content to the template

- Right click on ViewController project, Choose new 'JSF Page Template' as shown below

- Give the proper name to the template , Choose the quick start template ( This is optional, You can have your own layout as well)
- Attributes - This section allows to define place holders for various attributes can be used such as 'title' , title can be different for each page , So that implementation page will supply required title to the template page. Below screenshot shows how to define attributes while creating template itself.



 - FacetDefinition - This section allows the implementation page to supply the content of the page to the template, I defined 'content' facet in my template, so that implementation page will supply the content to the template using this facet.

- After defining 'FacetDefinitions' and 'Attributes' in template, then below screenshot shows how to use them in template
- In this example, 'uploadFlag' attribute used in <af:form> element as shown below
- 'title' attribute used to display the title of the page.
- 'content' facet used in 'center' facet.

- Next step is to create implementation page, Create a jspx page and extend to newly created template as highlighted below.

- Supply values for 'title' and 'uploadFlag' attributes which are defined in template as shown below

- Define the content in 'content' facet as shown below

- Below is how output looks like.


Thursday, September 12, 2013

How to Set Default value to SelectOneChoice component in ADF

This blog explains about setting default value as first item in the <af:selectOneChoice>. This is very very common requirement in day to day development activity using Oracle ADF.

-  Define List of Values to the attribute as shown below, In this example I have created 'List of Values' for 'EmpName' attribute using 'CustomerROVO' as shown below screenshot.


- Define 'Groovy Expression' to 'Value' attribute to get the specific default value as shown below. Refer to How to Use Groovy Expressions to know more about usage of Groovy expressions. This groovy expression invokes Application Module Impl method and retrieves the required default value.


- Below is code snippet, Get First row in 'CountryROVO' , and returns the 'CountryName' as shown below

- Below is code how it looks like when you bind 'EmpName' attribute on to page as <af:selectOneChoice>

- You are done, Run the page and you would see default value as shown as below

Approach 2

Use below groovy expression as shown below.
-  RegionsLOVVA.first()?.LookupCode , RegionsLOVVA is the view accesor for the Region Field. LookupCode is the short code which sets to this field.