Tuesday, August 16, 2011

Execute a default command button on clicking 'Enter' anywhere in the af:form in Oracle ADF?

This can be achieved by configuring the defaultCommand property of the af:form tag in the jsff page fragment or jspx page document in Oracle ADF.

We have to configure defaultCommand with the id attribute of the command button inside the form whose action should be invoked by default when the enter key is pressed with focus inside the form. If defaultCommand is not specified, no action is invoked when the enter key is pressed with focus inside the form.

For example:

<af:form id="f1" defaultCommand="pt1:cb4">

Thursday, May 12, 2011

Get the Application Module instance in backing bean from Data Control in Oracle ADF?

Sometimes we might need the view object instance or the application module instance in the manged bean in the view controller project. The following code snippet is a sample to do the same

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCDataControl;
import oracle.jbo.ApplicationModule;

public static ApplicationModule getAMOfDataControl(String name){
    BindingContext bindingContext = BindingContext.getCurrent();
    ApplicationModule appModule = null;
    if (bindingContext != null) {
        DCDataControl dc = bindingContext.findDataControl(name);
        if (dc != null) {
            appModule = (ApplicationModule)dc.getDataProvider();
        }
    }
    return appModule;
}

Once we get the application module, we can get the required View Object instance.

Friday, September 24, 2010

Highlight the currently selected row with a different color in ADF table

The following styleClass EL expression would achieve the required functionality

<af:table value="#{bindings.EmployeeDetailsVO.collectionModel}"
          var="row" rows="#{bindings.EmployeeDetailsVO.rangeSize}"
          styleClass=#{row.row ==  bindings.EmployeeDetailsVO.currentRow ? 'background-color:Green;' : 'default'}
          emptyText="#{bindings.EmployeeDetailsVO.viewable ? 'No results'  : ' Denied.'}"
          fetchSize="#{bindings.EmployeeDetailsVO.rangeSize}" rowSelection="single"
          rowBandingInterval="1" columnStretching="last" autoHeightRows="-1" id="t2"
          disableColumnReordering="true">

Sunday, March 28, 2010

convert java.util.Calender to java.util.date

import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;

public class DateUtils {
    public static void main(String [] args) {
        Calendar cal = Calendar.getInstance();
        Date d =  cal.getTime();

        SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy HH:mm aa");
        String documentDate = sdf.format(d);

        System.out.println(documentDate);
    }
}


Sample output

Mar 28, 2016 11:36 AM

Thursday, March 11, 2010

How to create Database tables based on Entity Objects in Oracle ADF?

Its a common scenario to create the Oracle ADF Business Components based on a particular database schema but what if we want to achieve the reverse scenario?

First of all let me clarify to the readers that we can create an entity object in ADF model project without basing it on any database schema as shown below















We have created the entity Object and we want to create the database table based on that.
  • Select the create Database Objects from the context menu

  • Select the entity object based on which the database table will be created
  • Once done, the confirmation dialog is shown as below