Retrieve the Old Value of an Attribute in the View Object

Sometimes we need to access the old value of an attribute, this is explained well by Chris Muir in ADF Insider video Retrieving the previous value of an ADF BC attribute. This can be done by using getPostedAttribute method in the EntityImpl class, this method gets the value originally read value for  a specific attribute from the database and it has a protected access modifier. But what if you want to access the old value in the View object and you don’t have a control on the Entity object; such as if the entity objects are deployed as ADF library jar and you don’t have any privilege to access or modify these entities; is it possible to access the old value from the view object? in this post I will show how do this in an easy way. Suppose we want to access the old value of the department name attribute in the DepartmentsView  which is based on Departments table in HR schema.

  1.  Create a transient attribute, OldDepartmentName in the DepartmentsView.
  2. Generate the DepartmentsViewRowImpl class, check the include accessors check box, this will add getter/setter methods for all the attributes of this view object. by default the getDepartmentName method will look like this: 
    * Gets the attribute value for the calculated attribute OldDepartmentName.
    * @return the OldDepartmentName
    public String getOldDepartmentName() {
    return (String) getAttributeInternal(OLDDEPARTMENTNAME);
  3. Override the getOldDepartmentName() method to:
         * Gets the attribute value for the calculated attribute OldDepartmentName.
         * @return the OldDepartmentName
        public String getOldDepartmentName() {
            byte status = EntityImpl.STATUS_UNMODIFIED;
            return (String) getAttributeInternal(DEPARTMENTNAME, status);

Now, the getOldDepartmentName() will return the old value from the database.

Leave a comment

Filed under ADF

Two Ways to Evaluate a Memory Scope Attribute Using Expression Language

All of us know how to evaluate a memory scope attribute using a dot notation syntax of the expression language.

Example: to access a request scope attribute, we use this syntax.


However, this syntax fails if the key has a dot (.) in its name. To overcome this limitation, expression language offers the string argument notation.

Example: to access a request scope attribute which has a (.) in its name, we use this syntax.



1 Comment

Filed under ADF

Create a Backing Bean for Existing Page

A backing bean is a special case of managed bean that has a one-to-one relationship to a single JSF page, and it exposes setter and getter methods for the components contained on the page. In Jdeveloper you can automatically expose UI components in a new bean when you create a new page by setting the Automatically Expose New UI Components in a New Managed Bean option as shown in the figure below.

Automatically Expose New UI Components in a New Managed Bean option

Automatically Expose New UI Components in a New Managed Bean option

But imagine you forget to set this option and later you decided to create a Backing Bean, do you need to explicitly bind each component to the backing bean?

Fortunately, you don’t need to bind the components manually, all you need is to open the page in the visual editor and  choose Design | Page Properties from the Jdeveloper menu bar as shown in the figure below:

Click on the page properties and then select the Component Binding tab from the page properties window, set the Auto Bind option, and create or select an existing managed bean.



Filed under Uncategorized

How to Disable Specific Dates in af:inputDate Component

Environment (JDeveloper,ADF Faces)

The inputDate component creates a text field for entering dates and (optionally) a glyph which opens a popup for picking dates from a calendar. However  in some cases we need to prevent the user from picking a specific days from the calender. In this post I will explain how to do this use case.

1- Create a simple JSF page and drag and drop af:inputDate component from the component palette into the newly created page.

2- Create a java class which implements org.apache.myfaces.trinidad.model.DateListProvider interface. This interface is used for providing a list of  individual dates within a given range.

3- Override the getDateList method, This method will generate a List of individual Date objects which will be rendered as disabled in a datePicker component.  An example is shown below.

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import javax.faces.context.FacesContext;

import org.apache.myfaces.trinidad.model.DateListProvider;

public class DaysBean
  implements DateListProvider
  public DaysBean()

  public List getDateList(FacesContext facesContext, Calendar calendar, Date date, Date date2)
    ArrayList disabledDates= new ArrayList();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    catch (ParseException e)
      return Collections.emptyList();
    return disabledDates;

4-Register the Java Class as Managed Bean in adfc-config.xml file.

       Register Java Class as Managed Bean in adfc-config.xml file

5- Go to the JSF page and select the inputDate component, from the property inspector select the DisabledDays property and bind it to the manged bean defined in the previous step.

<af:document title="Test.jsf" id="d1">
<af:form id="f1">
<af:inputDate label="Date" id="id1" disabledDays="#{daysBean}"/>


 this binding requires periodic roundtrips. If you just want to disable certain weekdays (e.g. Saturday and Sunday), use the disabledDaysOfWeek attribute!

6- Run the page, and check that the date is disabled.

01/01/2013 is Disabled

Moreover, if the user enters the date manually without using the date picker, an error message will be shown to the user.

Error Message When the date is Entered Manually

download the sample application TestDisableDays.rar

Please change the file extension to .zip or .rar after download.

Leave a comment

January 24, 2013 · 10:59 am

Application Development Framework Implementation specialist

Today, I took the Oracle Application Development Framework 11g Essentials exam (1Z0-554). Fortunately I passed it, and I am now an Application Development Framework Implementation specialist.

O_Certified Specialist_clr


Filed under ADF

2012 in review

The stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

4,329 films were submitted to the 2012 Cannes Film Festival. This blog had 50,000 views in 2012. If each view were a film, this blog would power 12 Film Festivals

Click here to see the complete report.

Leave a comment

Filed under Uncategorized

How to Solve oracle.jbo.ConfigException: JBO-33001

Environment (JDeveloper, ADF BC, ADF Faces)

When you work with large application which contains more than one Model/one ViewController projects, you need to set the project dependency between the model and the view controller project., failing to do this you may face this exception.

oracle.jbo.ConfigException: JBO-33001: Configuration file /model/common/bc4j.xcfg is not found in the classpath.

To solve the problem, double click the viewController project to open project properties dialog, and select the the Dependencies node  and click the Edit Dependecies icon to add a dependency on the build output path or on one or more deployment archives.

Hope this will help someone faced the same problem.


Filed under ADF

Simple way to convert af:inputText to upperCase,lowerCase,capitalize

Environment (JDeveloper,ADF Faces)

Sometimes you need to force the user to enter upperCase or lowerCase or capitalize letters for input text component. fortunately, there is an easy way to do this by setting contentStyle of the input text.

  • To enforce the user to enter upperCase text use this style:
<af:inputText label="Label 1" id="it1" contentStyle="text-transform:uppercase;"/>
  • To enforce the user to enter lowerCase text use this style:
<af:inputText label="Label 1" id="it1" contentStyle="text-transform:lowercase;"/>
  • To enforce the user to enter capitalize (InitCap) text use this style:
<af:inputText label="Label 1" id="it1" contentStyle="text-transform:capitalize;"/>


Filed under ADF

How to convert StackTrace to String

Recently we had a requirement in our application that whenever an exception occurred we   need to store all StackTrace elements in the application’s log file. So we need to get a string representation of the  StackTrace.

Starting by searching in java.lang.Throwable class, we have found two methods   printStackTrace(PrintWriter)  which prints the throwable and its backtrace to the specified print writer, and printStackTrace(PrintStream) which prints the throwable and its backtrace to the specified print stream. So which method best fit our case?

To answer this question we referred to API documentation for PrintStream and PrintWriter classes and we found this statement:

All characters printed by a PrintStream are converted into bytes using the platform’s default character encoding. The PrintWriter class should be used in situations that require writing characters rather than bytes.

So our choice was printStackTrace(PrintWriter)  method and here is the method we used.




public String getStackTrace(Exception e){
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
return stringWriter.toString();

1 Comment

Filed under Java

Oracle JDeveloper and Oracle ADF 11g Release 1 (

Oracle JDeveloper Release 1 ( is now available for download.

check Oracle JDeveloper and Oracle ADF 11g Release 1 ( New Features


Leave a comment

Filed under Uncategorized