Sunday, May 27, 2007

ExecuteWithParams in your Oracle ADF application

Recently I was researching Google Analytics data for my blog. I have noticed, that there are many search engine keywords with 'ExecuteWithParams' word. Really, this action plays one of the central roles in Oracle ADF BC application, it is used quite frequently and people want to know more about it. So, I have decided to build sample application focused on 'ExecuteWithParams' functionality.

Sample application -, is based on DEPARTMENTS table from standard HR schema. Business logic of developed sample is based on idea to allow edit operation only for departments from specified geographic region. Edit form allows to change department location, but only within specified region. And finally, region is specified in property file called

In order to achieve business logic requirements I have changed default SQL for Departments View Object - I have joined Departments table with Locations and Countries, in order to retrieve departments only from region specified in :regionIdVal bind variable:

Value for :regionIdVal is assigned in ExecuteWithParams action.

Departments edit form contains location component, I have implemented this component as af:selectOneChoice. It allows to select only locations within specified region. This means, ExecuteWithParams should be also applied for this component. I have edited default SQL for Locations View Object, this View Object is used as a List Data Source for af:selectOneChoice. Modified SQL statement:

Value for :regionIdVal is assigned in ExecuteWithParams action also. This value is defined in file, for example: regionId=2, you can change it's value at any time.

Let's switch to ExecuteWithParams action. I have created required actions in such way - at first I have dragged and dropped needed data controls and after that I have created actions in page definition file manually. ExecuteWithParams action for Departments View Object definition:

You can notice, that action have one parameter - regionIdVal. When action is created, don't forget to add executable - invokeAction into page definition file for ExecuteWithParams. This will enable automatic execution of defined action. Executable for DepartmentExecuteWithParams action:

Action and executable for Locations View Object can be created in the same way.

And..., how it works:

Edit form shows departments only from region specified in property file, at the same time af:selectOneChoice allows to choose locations only from specified region also.

When running sample application, don't forget to add adf-faces-impl.jar and jsf-impl.jar to application's WEB-INF\lib directory.

Thursday, May 24, 2007

Oracle Fusion Middleware Regional Director nomination

I was informed this week, that I have received Oracle Fusion Middleware Regional Director nomination. Thanks Oracle!

I believe, this nomination will help me to share knowledge with community, and also it will help to find new innovative ways for knowledge sharing. I will do my best! ;)

Sunday, May 20, 2007

Spring in Lithuania

During this weekend I was outside of the city. Finally, Spring and hot weather have reached us also. I have captured flowers from Lithuanian forest, seems really nice ;)

Sunday, May 13, 2007

Templating in Oracle JDeveloper 11g

As probably everyone of you have heard - this week was released Oracle JDeveloper 11g Technical Preview. I have looked through 11g release and should say, that if Oracle JDeveloper 10.1.3 was smart enough tool, then Oracle JDeveloper 11g is simply smart :). There are a lot of new and useful functionality implemented in tool itself. During sample application development I have noticed many enhancements comparing to previous release, those enhancements available in Oracle JDeveloper 11g will help to be more productive and to develop more effective applications.

I have decided to build my first sample on Oracle JDeveloper 11g to describe Oracle ADF templating functionality. In fact, it was real pain when implementing applications with many pages and similar functionality in each page. However, now that pain should go away, because in Oracle JDeveloper 11g UI and also data logic templating becomes really simple. If you are interested, you can watch the online screencast - JSF Page Templating, available on OTN.

Developed sample application - is based on standard HR schema and provides three JSPX pages, two of them are based on developed template. I have developed this sample in similar way like in Frank Nimphius screencast, however additionally I have used page definition file for template. Developed template contains two parts - Master and Detail area. Master area is empty, there facet 'master' is declared, later when real page will be created from template, I will put into this area Master data for Employees entity. Into Detail area I have dragged and dropped a read-only table based on Employees entity. This means, that structure in Master will be specific for each form, but structure created in Detail area will be the same in all forms. If requirements will be changed, Detail part structure can be easily updated in template document, all forms created based on template will be updated automatically. Developed template:

To show how this template can be used, I have created two pages (editDepEmpl1.jspx and editDepEmpl2.jspx) based on the same template. Both of those pages contain Master-Detail relationship implemented, Detail part is the same and Master part is different. Page flow diagram:

First page provides a form for Department name editing, second page provides a form for Department location editing. Both pages are invoked from main.jspx:

Page for editing Department name:

Page for editing Department location:

Oracle ADF in JDeveloper 11g provides additional feature for data tables - filtering (have you noticed that line with empty fields above table header?). Let's say we want to apply filtering for First Name column using 'A%' string:

Ok, application is working and everything is fine. But, let's imagine such situation - our analyst isn't working so good as we - he/she have decided to change primary functional requirements and to remove filtering feature from detail table. If you are working with previous release, you will iteratively apply the same routine steps for all tables needed to be changed. But, in Oracle JDeveloper 11g situation is different, here you can go directly to template document and make changes only once - remove filtering option. Changes in template document will be applied for all pages based on that template. And really, table is changed:

It seems Oracle JDeveloper 11g doesn't put standard JAR libraries into application folders, application size is reduced and there is no need now to copy into WEB-INF/lib standard libraries.

Sunday, May 6, 2007

Create/Edit operations and setCurrentRowWithKeyValue action in Oracle ADF

This post is based on my previous post - Invoking Create method programmatically. I have decided to extend it and to show how Edit form for newly created data should be opened. While Create functionality is reused, in Edit form Master-Detail relationship is implemented. Master part is implemented using ADF Faces form component, in Detail part ADF Faces table component is used. Table is created with dropdown list, according to solution described in Steve Muench screencast Nr. 7, available at JDeveloper/ADF Screencasts. In this post, I will be mainly focused on data transfer between Create and Edit forms.

Ok, let's say we have created custom Create form using a method in Application Module class. At the same time, Edit form functionality is developed based on the same View object as for Create form, but only with one difference - it is developed in declarative way, using JDeveloper wizards. Let's make a test and see what we will get. Create form:

When Creat button is pressed, Edit form is opened, but displayed data isn't correct:

Developed sample application -, handles this action correctly. Sample is based on LOCATIONS table from standard HR schema. Data from DEPARTMENTS table is used in Detail part of Master-Detailed relationship implemented in Edit form.

Value for primary key column is generated by database sequence, so for primary key column is assigned DBSequence type. So, how to open correct data in Edit form after Create operation is performed? Needed steps:
  1. From createLocation method implemented in Application Module class, you should return primary key value for newly created row - newLocation.getLocationId().getSequenceNumber();
  2. In Create form JSPX page Backing bean implemented action method binding, store returned primary key value into managed bean - JSFUtils.setManagedBeanValue("valueHolder.locationId", ((Number)result).stringValue()); Please, notice that oracle.jbo.domain.Number is converted to java.util.String, it is because setCurrentRowWithKeyValue accepts java.util.String type values
  3. In page definition file for Edit form, define setCurrentRowWithKeyValue action, in developed sample it looks similar:

  4. Don't foget to add in the same page definition file invokeAction element for defined setCurrentRowWithKeyValue:

When listed steps are passed, Edit form should be opened correctly. Let's test again, Create form:

When Create button is pressed, Edit form is opened with correct data:

When running sample application, don't forget to add adf-faces-impl.jar and jsf-impl.jar to application's WEB-INF\lib directory.