Sunday, July 29, 2007

Web Service Invocation in Oracle ADF

Some time ago I was blogging about how to access persistence layer through Web Service interface - Web Services and Oracle TopLink. I have mentioned, that I will extend developed sample and will show how it is possible to use Web Services in Oracle ADF View layer.

Frank Nimphius have posted this week how-to article on OTN - Using Web Services with Complex Return Types in ADF. In this article, Frank describes in detail how to include and use your Web Service in Oracle ADF application. I have decided to apply described steps and develop client application - for my previously developed sample Web Service -

In developed client application, data retrieved from Web Service, is shown in af:table component:

Data for all three columns is retrieved from Web Service, however labels for regionId attribute are provided from client application Model layer. In Oracle ADF, data from Web Service can be easily merged with data provided by Model layer.

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

Saturday, July 21, 2007

Invoking BPEL Process from Oracle ADF Application

In today post I have decided to describe and show how application developed using Oracle ADF can fit into SOA (Service-Oriented-Architecture). SOA is important technology, because it allows developers to find common language with business analysts and as result to develop more useful systems. Simply speaking, SOA allows to participate in system development both parties - IT and non IT. IT folks develop technical things and non IT people are allowed to manage system logic. My goal is to show, how it looks in reality, and how it works with Oracle JDeveloper and Oracle SOA Suite. Sample applications are developed using Oracle JDeveloper and BPEL process is tested on Oracle BPEL Process Manager For those who will want to look further, I recommend to browse through Guides and Tutorials available on Oracle BPEL Process Manager Information page.

Web application - and synchronous BPEL process - are provided as sample applications. Web application Model layer is implemented using Oracle ADF Business Components and is based on standard HR schema, in View layer ADF Faces components are used. Synchronous BPEL process access HR schema using Oracle TopLink.

Developed logic - in Web application users can search for particular employee and select him/her for salary update process. Salary update is based on current salary and applied bonus value. Salary update business logic is implemented in BPEL process. So, it's where we can see a power of SOA - salary update business logic can be changed at any time by non IT people, they will just need to modify defined process.

I will start from process part description. Implemented BPEL process diagram:

In first step, process receives input. In second step, conditional logic is applied and process output is calculated. When process output is known, data is transformed to be compatible with EMPLOYEES table structure from HR schema. After transformation step, employees data update in database is invoked and process is finished.

As it was described, salary update process is based on two parameters - current salary and applied bonus, however employee ID is also needed. Process parameters are described in XSD document:

Process logic is implemented in switch activity. Switch activity rule is based on bonus variable value:

When process output is calculated, data should be transformed in order to be stored in EMPLOYEES table. Transformation can be defined using Oracle JDeveloper wizard tool:

And finally, transformed data is used in database update through Invoke activity:

Yes, database table will be updated from BPEL process. And there is no magic, simply Oracle TopLink object-relational mapping functionality is used. Complete project structure view in Oracle JDeveloper navigator:

Process part description is completed, now we will move to Web application part. Web application contains two forms, first is Search Employees form:

Second form - Edit Employee Salary, can be opened for selected row:

Update Salary button here invokes BPEL process. Salary calculation is done outside of Web application, through Web Service submited values are passed to process where are modified and stored to database. In Web application refresh action is executed and updated values are shown:

You can notice, that salary value is increased by 100, this logic is defined in BPEL:

You may wonder, how BPEL process can be included into Web application developed using Oracle ADF. But it is simple, Oracle JDeveloper provides complete solution - you just need to provide WSDL URL and Data Control for available operations will be generated and displayed in Data Control pallette:

BPEL process is accessed through Web Service specified in DataControls.dcx file:

Action related to BPEL process is defined in page definition file in standard way:

Executed BPEL process instance can be explored from Oracle Enterprise Manager 10g BPEL Control window - executed process steps are represented in visual flow and values available in each step are provided:

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

Saturday, July 14, 2007

Opening Report Window in ADF Faces

Such requirement as opening report window can be assumed as easy one. But, when I have received request for solution, it was not so easy to find it :). On OTN Discussion Forum there are questions on this topic, but no clear answers. Opening report window in ADF Faces is important requirement, because quite often Oracle Reports are needed to be opened from Web application.

Requirement description:
  1. In JSPX page we have a table or form where parameters can be entered
  2. On the same page we have a button. When it is pressed, entered parameters are passed to backing bean method, where based on provided parameters URL string is generated
  3. Generated URL is opened in Web Browser new tab or window
Main question here - how to open new tab or window when button is pressed. To implement solution for this requirement, at first I have tried to use JavaScript with binded dynamic parameter for URL generated in backing bean. This solution wasn't suitable, because JavaScript is always executed one step forward comparing to backing bean Java code.

I have found another solution, it is quite simple and is implemented in my sample - af:commandButton doesn't have Target property, but h:form does. Submit action of af:commandButton component, placed into h:form with Target property set to _blank, is always executed in new tab or window (depends on Web Browser).

Developed sample implements two h:form components - one is used for parameters and second for button:

Second h:form component property Target is set to _blank:

JSPX page backing bean contains some dummy code for URL generating. URL is opened using ExternalContext obtained from FacesContext:

This code is executed when Open Report button is pressed, URL is generated according to submited parameters. Data available in parameters form should be auto submited, in order to be available from second form where Open Report button is implemented:

Generated URL is opened in new tab:

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

Tuesday, July 3, 2007

Problem with samples hosting again! (updated)

Hosting problem is solved and all sample applications are available for download. University stuff was really quick, thanks!

I have noticed today, that sample applications are unavailable for download. Sorry for that, I will fix it in short time. Thanks!

Since I'm not a student anymore, university have closed my account, but I will ask to open it again :).

Post updated: 7/4/07