Anil's Blog is Best Viewed on GOOGLE CHROME

Sunday, May 10, 2009

Overview of the OA-Framework Components

OA-Framework is a very rich and powerfull development tool ; we will not start an in-depth discussion about how it works, but here is the main vocabulary you will need :

MDS - The declarative metadata repository used with 11.5.10+ OA Framework applications. This replaced the older AK Repository.

The first component is the page ; a page is a set of regions (header, footer, table…), and each region can contain items (field, button, checkbox...), or other regions.

Pages are XML files found under $APPL_TOP/MDS folder example:-


BC4J : Business Components for Java
BC4J is a set of java libraries that meshes SQL database concepts like views, tables and transactions into the Java world via View Objects (VOs), Entity Objects (EOs), and Application Modules (AMs).

All BC4J components are found under $JAVA_TOP example:-

Application Module, View Object, View Link, PVO found under:-

Controller found under:- $JAVA_TOP/oracle/apps/pa/project/webui/

Entity Object, Validation View Object, Validation Application Module found under:-

View Object
In the simplest terms, a BC4J view object encapsulates a database query and provides iteration over and access to the view rows in its result set.

Entity Object
When we handle data through a page - INSERT / UPDATE / DELETE - we do this by using an Entity Object. An Entity Object is a java representation of a table ; each column of the table is mapped to an "Entity Attribute".

Application Module
An application module is a container for related BC4J objects. The AM is connected to the database, and is responsible for the commit and rollback of a transaction.

The controller is the java code in charge of loading a page when we call it. It is also in charge of handling an event on a page, like a click on a button, or the call of a List Of Values. It has three Methods:-

1. ProcessRequest
2. ProcessFormData
3. ProcessFormRequest

Find the right JDeveloper Patch for OAF development

To determine which patch to use, you can simply check the framework version in your instance by using http://host:port/OA_HTML/OAInfo.jsp, then choose the matched one.

11.5.10K = patch 4045639
11.5.101CU = patch 4141787
11.5.102CU = patch 4573517
11.5.103CU = patch 4725670

It would be interesting to have a survey regarding what framework versions are being used for OAF development. Please post your current development version in a comment; I will publish the results at a later stage.
Checkout Metalink note 416708.1 for the up to date list of OAF releases.

Saturday, May 2, 2009

How do I find rows that were selected by the table selector

Application Module Code

import oracle.jbo.RowSetIterator;

public void checkSelectedrow()

OAViewObject vo = getTeamRoleListVO1();
int fetchedRowCount = vo.getFetchedRowCount();
RowSetIterator selectIter = vo.createRowSetIterator("selectIter");

if (fetchedRowCount > 0)
// Save the original range size and range start.

//Creates a Transient Attribute of "String" type.

for (int i = 0; i < fetchedRowCount; i++)
TeamRoleListVORowImpl rowi = (TeamRoleListVORowImpl)selectIter.getRowAtRangeIndex(i);
String selectFlag = rowi.getSelectFlag()+""; 

if("Y".equals(selectFlag )
 //  Getting selected row.
 selectIter.closeRowSetIterator(); }

Retaining issue in LOV whenever any Event occurs


You have a messageLovInput and you also return the value in some column like messageStyledTextbut as soon as any event fires on page the value in the messageStyledText wipeout.

How to Overcome this issue

Instead of creating item of messageStyledText create item of type messageTextInput and set it read only property to "TRUE".

This will certainly solve the issue.

Insert a new record by createRow()

In Application Module Impl

Row row = vo.createRow();

How-to persist and retrieve user defined SQL objects using JDBC

How to return an array from a PL/SQL Stored function

Sequence in EO

First Cross check that Create Method is clicked in EO.

Then go to EOImpl

public void create(AttributeList attributeList)

Good Java Basic Examples

Partial Page Rendering (PPR)

A mechanism for selectively refreshing parts of a page (as opposed to the whole page) in response to user actions. For example, if a user sorts a table, only the table's contents changes; the rest of the page remains the same.

The FND: Disable Partial Page Rendering profile option must be set to No. If this profile value is set to Yes, a Go button renders next to each item you configure to raise a PPR event).

Important :-
Note: UIX currently does not support the ability to hide components whose direct parent region is a cellFormat or a rowLayout. As a workaround, to hide a component such as a button in a cellFormat, add flowLayout to your cellFormat region first, then add the button to the flowLayout

SPEL syntax : ${oa.ViewInstanceName.viewAttributeName>}
Example  ${oa.EmployeePVO1.EmpManagerRender}

You need to set this syntax on the attribute on which you want to enable PPR in the Parameters window. At runtime, this item will render according to the value of the EmpManagerRender attribute in the EmployeePVO1 view object.

To enable PPR on page, you must create an OA Framework standard applications properties view object (PVO) including a transient attribute for tracking the state of the visible property for the Attribute.

The application properties view object should be created in the same package as your module's other UI BC4J components. Note that you should have only one application properties view object per application module (it can include attributes used by different pages that share the same root UI application module).

Warning: This lesson assumes that you have completed the Create Exercise from Tutorial - shipped in Jdev Itself, and builds on that work. If you have not completed this exercise, please do so before proceeding

In this exercise we will implement the Partial Page Rendering.  Depending upon the value in Position Poplist will change the "Render Property" of Manager.

If the Position poplist value is null or PRESIDENT, the Manager field does not display. If it is set to any other value, the Manager field displays and is required.


1. Create an "Application Properties" View Object
2. Add the EmployeePVO View Object to the EmployeeAM
3. Configure the Position Item to Fire a PPR Action When Changed
4. Configure the MgrName Item to React to PPR Events
5. Implement PPR Event Handling in Controller and Application Module Impl

Create the EmployeePVO View Object

In the oracle.apps.ak.employee.server package, create the EmployeePVO view object.
In the Attributes page, select the New... button and create a transient primary key attribute with the following properties:
         * Name: RowKey
         * Type: Number
         * Updateable: Always
         * Key Attribute (checked)

Select the New... button again and create a transient attribute with the following properties:

        * Name: EmpManagerRender
        * Type: Boolean
        * Updateable: Always

You do not need to generate any Java files for this PVO.

After you create the PVO, reopen and navigate to the Tuning page. Check the Enable Passivation and For All Transient Attributes checkboxes (it's important that the transient attributes in an application properties view object be properly passivated).

Add the EmployeePVO view object to the EmployeeAM.[Create the EmployeeAM if not created yet.]

Configure the Position Item to Fire a PPR Action when changed. Set the following properties for the Position item in your page:

Property                                                                    Value

Disable Server Side Validation                                    True
Disable Client Side Validation                                     True
Action Type                                                               firePartialAction
Event                                                                    empPositionChange
Submit                                                                       True

Step 4
Configure the MgrName Item to React to PPR Events

Set the value of the Rendered property to the following SPEL ("Simplest Possible Expression Language") syntax indicating that the property value should be obtained from the EmployeePVO1 instance's EmpManagerRender attribute:


Step 5
Implement PPR Event Handling

Controller Code

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
      // Always call this first.
      super.processRequest(pageContext, webBean);
      // Iniitalize the ApplicationPropertiesVO for PPR.

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    // Always call this first.
    super.processFormRequest(pageContext, webBean);

if ("empPositionChange".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
      // The Position poplist PPR change event has fired.

Application Module Code

public void init()
OAViewObject appPropsVO = (OAViewObject)findViewObject("EmployeePVO1");
if (appPropsVO != null)
   if (appPropsVO.getFetchedRowCount() == 0)
// Set the primary key value for this single-rwo VO.
   OARow row = (OARow)appPropsVO.first();
   row.setAttribute("RowKey", new Number(1));

public void handlePositionChangeEvent()
// Get the special, single-row application properties and make the first (only) row current.

OAViewObject vo = (OAViewObject)findViewObject("EmployeePVO1");
OARow row = (OARow)vo.first();

// Get the value of the view object attribute with the position code.

OAViewObject empVO = (OAViewObject)findViewObject("EmployeeFullVO1");
OARow empRow = (OARow)empVO.getCurrentRow();

String position = (String)empRow.getAttribute("PositionCode");
  if ((position == null) || ("PRESIDENT".equals(position)))
  row.setAttribute("EmpManagerRender", Boolean.FALSE);
   row.setAttribute("EmpManagerRender", Boolean.TRUE);
Read Chapter Dynamic User Interface in Dev Guide for more details.....

Profile Option to get HOST & PORT

Profile option "CSF: eLocation Map host name" to get the host name of Oracle Database.
Profile option "CSF: Database port to receive data" to get the port number.

Comparision of Dates in Controller

OAViewObject oaviewobject1 = (OAViewObject)am.findViewObject("NewEmployeeVO1");

if (oaviewobject1 != null)
oaviewobject1.reset(); //New line added; //new line added
OARow row = (OARow)oaviewobject1.getCurrentRow();

Date sDate =(Date)row.getAttribute("EffectiveStartDate");

Date eDate =(Date)row.getAttribute("EffectiveEndDate");
java.util.Date VChangeDateTime =
new java.util.Date(sDate.timestampValue().getTime());

if (sDate !=null && eDate !=null)
long m1 = sDate.timestampValue().getTime() ;
long m2 = eDate.timestampValue().getTime();

long diff = m2 - m1;

int diffDays = Math.round(diff / (24 * 60 * 60 * 1000));

if (diffDays >365)
System.out.println("Date is greater than 365");

System.out.println("Date is less than 365");

To Find out the event Occur

Controller Code:

String event = pageContext.getParameter(EVENT_PARAM);

Table Events

The various table events are:
1. Navigation - user selects the Next or Previous link to navigate between different ranges of rows.
2. Sorting - user selects a beveled column heading to sort that column in ascending or descending order.
3. Insertion of a new row - user selects the Add Another Row button.
4. Recalculate column Total - user selects the Recalculate button to update the column total.
5. Detail Disclosure - user selects the Hide or Show link to collapse or expand the detail disclosure region.
6. Table Control - user selects the Action/Navigation button in the table Control bar.

You may wish to familiarize yourself with the set of UIX "hidden" fields so you can capture these events and implement custom behavior on them. The "hidden" fields are UIX attributes in the UIConstants interface.

These parameters are set only when a form submit event is induced from a table. They are:
1. SOURCE_PARAM - indicates the source of the event that is generating the current browser request.
This maps to the name attribute of the web bean. If you wish to check whether a table generated an event, you include in your code:

if (tableBean.getName().equals(pageContext.getParameter(SOURCE_PARAM)))

2. EVENT_PARAM - indicates the event generated by a web bean (a table, in this case). The possible events generated by a table are:

3. GOTO_EVENT - when 'Next' or 'Previous' navigation links are selected

4. SORT_EVENT - when a column header is selected to sort that column

5. HIDE_EVENT - when the 'Hide' link of a detail disclosure is selected

6. SHOW_EVENT - when the 'Show' link of a detail disclosure is selected

7. ADD_ROWS_EVENT - when the 'Add Another Row' button is selected

8. UPDATE_EVENT - when the total row 'Recalculate' button is selected

9. VALUE_PARAM - indicates a value that is relevant to a particular event:

10.When a detail disclosure Hide/Show is selected, the value parameter contains the row index
corresponding to the row whose Hide/Show was selected.

11. When the 'Next' or 'Previous' link of table navigation bar is selected, the value parameter contains the index of the first row of the current range. For example, when the row range 1-10 is displayed, the value is 1 and when the row range 11-20 is displayed, the value is 11.

12. SIZE_PARAM - indicates the number of rows currently displayed in the table (relevant only to the navigation event).

13. STATE_PARAM - indicates the current sort state (ascending or descending) of the column on which sorting is invoked (relevant only for the sort event). Example Usage

To check for the "Add Rows" event:

if (tableBean.getName().equals(pageContext.getParameter(SOURCE_PARAM)))
&& ADD_ROWS_EVENT.equals(pageContext.getParameter(EVENT_PARAM)))

raiseDeveloperException - To see output OnScreen

pageContext.raiseDeveloperException(new OAException ("Test VALUE IS "+ pageContext.getParameter("fruitRadioGroup")));