Sunday, April 27, 2008

Those familiar with Oracle Forms, probably know how often in Forms is used UI interface pattern, which splits record into table and form. Simply speaking, one part of record attributes is displayed in table component and second part of attributes is displayed in form component. In Oracle Forms it is usually done for long records with many attributes in order to save space in visual form layout.

You can download sample where this approach is implemented - ADFTableForm.zip. Its simple sample and main trick here is not to forget to specify PartialTriggers property for dependent form element. PartialTriggers must point to parent table Id name:

This means when user will select row in parent table, dependent form will be updated with data from selected record. This action is done automatically in ADF, you just need to use attributes from the same Data Control element.

In developed sample application, when user selects row in a table, Salary and Phone Number fields in dependent form are updated with values from selected row:

Create functionality works as well. When Create button is pressed, empty row is displayed in parent table and fields in dependent form become empty:

Sunday, April 20, 2008

I was blogging about use of domains in ADF Business Components previously - Oracle Object Types in Oracle ADF. However, I have described domains there from Oracle Object Types implementation perspective, but its possible to use domains for validation rules. With domains you can implement custom validated data types for java.lang.String, java.lang.Long and other Java types. Main benefit of validated data types implemented with domains is reusability. Let's say if there are attributes in several Entity or View objects and the same validation rule is applied for those attributes, its more wise not to repeat this validation rule, but to put it into domain. I will explain in this post, how to do this.

You can download developed sample application - ADFDomainValidation.zip. To run this sample, you need to have standard HR schema in your database, I'm personally using Oracle XE. Just right click faces-config.xml file and select Run, application will be started.

I have implemented domain called - SalaryDomain. This domain is based on java.lang.Long type and it validates for positive salary amount.

When JDeveloper generates domain, Java class for this domain is generated as well. This class contains standard method - validate(). You can put your validation code here. Its important to notice, that validation logic will be applied for existing and for new data. This means validation is applied during querying from database process. I have implemented simple validation rule - salary value can't be negative:

And now, when domain is created and validation logic is implemented, we can apply our domain as a Type for attributes. Applying domain for MinSalary and MaxSalary attributes from Jobs Entity object:

Applying domain for Salary attribute from Employees Entity object:

So, you can notice the same validation logic is applied for three different attributes in two different Entity objects.

When application is running and user is trying to assign negative value for MinSalary attribute:

Monday, April 14, 2008

Today I was participating in workshop - Oracle Forms: The Road To SOA, this event is described in my previous blog post. I have done JDeveloper 11g Masterclass session during this event, it was 2 hours session and was based on functionality described here. Event was successful with about 50 people auditory.

During my session I have developed 2 applications. You can download those applications I have developed on the fly and run with JDeveloper 11g Technology Preview 3 - Forms2SOA.zip and FormsToSOAComposite.zip. First application is main application based on standard HR schema from Oracle XE database. Second application implements ESB flow to write into file and is exposed through Web Service.

Here is Model part structure I have developed:

ViewController part structure is a little bit more complex:

I have designed Page Template with Panel Splitter component. You can see in Job Tab LOV component, in the second part of Panel Splitter is created Region with Employees table implemented as Fragment:

When value from LOV component is selected, table is automatically updated with Employees with selected job.

In the second tab - Job Edit, we can edit job selected from LOV component. This functionality is implemented in Fragment as well and comes to main page as Region:

However, this second Region is more complex, it provides a choice to display Graph component as well:

Fragment with Graph is displayed based on conditional logic, if Show Graph check-box is selected - Graph is shown:

Developed SOA composite is based on 3 parts - Exposed Web Service, Mediator and File Adaptor:

Exposed Web Service is invoked from application developed with Oracle ADF. File Adapter writes data received through Web Service to a file in File System.

Before you will invoke developed SOA Composite in your environment, you need to change WSDL location in DataControls.dcx file, available in Forms2SOA application:

Wednesday, April 2, 2008

In this post I want to describe how its possible to implement Create-Read-Update-Delete (CRUD) functionality with JDeveloper 11g. There are many approaches that can be used to implement those functions with JDeveloper 11g. Today I will describe how to develop form based CRUD functionality.

Main advantage of developed sample application - ADF11_CRUD.zip is that CRUD functionality is implemented with Regions and based on ADF Task Flow. This allows to implement logic in separate forms, but to present to user with one page. Regions and ADF Task Flows are features introduced from JDeveloper 11g, in previous releases it was possible to implement CRUD functionality with forms in separate pages or to play with forms rendering using one page. However, both approaches weren't ideal, since users usually don't like to navigate from page to page and on the other hand to implement full functionality inside one page was potential source for bugs.

I have designed ADF Task Flow in my sample application:

Page fragment that is opened first, when running defined task flow is - departments. This fragment contains Master information for Detail part accessed in subsequent pages. Implemented page fragments are aggregated by ADF Task Flow and registered to be used in main.jspx page as Region. ViewController layer structure, one JSPX page and four fragments:

When you will run sample application, main.jspx will be opened and you will see departments fragment:

Here you can choose one of the Departments and go to Detail part - Employees CRUD functionality. User still will be on the same page, however new fragment will be opened - employeesUpdate:

From here we can involve Create functionality in employeesCreate fragment:

You can notice that JobId is read-only in this form, it's because I'm assigning default value for this attribute. However, it can be changed later. JobId is assigned from value stored in #{processScope.JobId}:

When new employee is created, employeesUpdate fragment will be opened automatically. Here you can update employee information:

And finally, when Delete button is pressed, confirmation fragment for Delete action is opened:

Delete action is invoked from Backing bean, I'm using removeCurrentRow() function to remove row from iterator: