Wednesday, August 29, 2007

ADF Task Flow in JDeveloper 11g

In JDeveloper 10g there is only one possibility to design application page flow structure - using JSF navigation flows. But sometimes, use cases require to implement complex page flow, that is not supported by JSF navigation flows. JDeveloper 11g brings ADF task flows in addition to JSF navigation flows. From Oracle JDeveloper 11g Technology Preview, Fusion Developer's Guide for ADF:

Task flows provide a more modular and transactional approach to navigation and application control. Like standard JSF navigation flows, task flows mostly contain pages that will be viewed. However, instead of describing navigation between pages, task flows facilitate transitions between activities. Aside from navigation, task flow activities can also call methods on managed beans, evaluate an EL expression, or call another task flow, all without invoking a particular page. This facilitates reuse, as business logic can be invoked independently of the page being displayed.

In developed sample application - ADFTaskFlow.zip, task flow is implemented for Department data editing. Sample is based on standard HR schema, available in Oracle XE Database. Application contains one JSPX page and this page is divided into two parts - in first part Locations are shown, in second part Departments are managed. Departments management requires to have two views - one for viewing and selecting, second for editing and saving. Additional requirement - to have Locations table displayed always. In JDeveloper 10g, we probably would implement such application with two pages, but in JDeveloper 11g we can use task flow functionality and implement it with one page.

In application Model layer, two entity objects are implemented - Departments and Locations. Based on those entities, View objects are generated and exposed as HrModule Data Model components.

Central role in developed application plays task flow implementation:

Task flow is available in task-flow-definition.xml file - two views and navigation cases are defined. You can define task flow components by dragging and dropping required elements to task flow diagram from Component Palette:


viewDepartments implements a table component with selection feature. When row is selected and opened for editing - editDepartments view is opened. In editDepartments you can change available data and commit it to database - viewDepartments will be opened automatically.

In order to use developed task flow, you can drag and drop it into your JSPX page. Select task flow in Application Navigator window:


When you will put it into your JSPX page, pop-up menu will be opened, where you can choose how task flow should be created:


In developed sample application, I have created task flow as Region.

And last step - JSPX page that contains a task flow, should be registered in adfc-config.xml file. In developed sample, I have just dragged and dropped main.jspx page into adfc-config.xml file:

Now we can check, how application screen look. Page contains two parts - Locations and Departments. Locations part is implemented as simple table with filtering feature, just to browse through data. In Departments part, task flow is implemented, first part of task flow - viewDepartments is shown here:


We can select any row in Departments table and open second part of task flow - editDepartment:


Edit form for Department data is opened in the same page and table with Locations is still shown - required behavior. Main advantage of task flow in this application - data for locations is always available and action can be performed in the same time. If user wants to change department location and wants to know more about new location - he/she can browse for required location in Locations table.


We set Munich city as a new location and press Save button - data is commited to database and first view of task flow - viewDepartments is opened.

16 comments:

Anonymous said...

Hi,

I Appologise for posting in a wrong place.

Currently I am implementing exception handling in my adf 11g project. I followed the way it has been implemented in SR DEMO application. But the problem I am getting is quite unexpected.

I Implemented custom PhaseListner,Lifecycle and errorHandler.But when application is throwing any exception, it is not coming to the reportException method of the customErrorHandler. Whereas, the corresponding methods of Phaselistner and lifecycle gets executed.
The following line in prepareModel method sets the errorHandler to customErrorHandler but this is not getting reflected when application throws any exception

if (!(ctx.getBindingContext().getErrorHandler() instanceof
TestErrorHandler)) {
ctx.getBindingContext().setErrorHandler(new TestErrorHandler(true));
}


Any Idea of what is going wrong here?

Andrej Baranovskij said...

Hi,

Can you send me your code? I will look into it and will try to reproduce described behavior.

Regards,
Andrejus

Mourado said...

Hi andrejus,

After runnning the application i have

oracle.jbo.JboException: Error getting property:queryDescriptor on bean:LocationsView1Query of type:oracle.adfinternal.view
.faces.model.binding.
FacesCtrlSearchBinding
java.sql.SQLException: ORA-01017: invalid username/password; logon denied

Andrej Baranovskij said...

Hi Mourado,

Seems like application can't connect to database. Have you checked username and password for database, it it correct?

Regards,
Andrejus

pachiappan said...

Hi andrejus,
If you can give the step by step details that you have done to create the application it would be helpful in understanding for the newbies like me.

Andrej Baranovskij said...

Hi,

I dont have step by step tutorial at hand for this application. But I'm ready to help, what particular step is not clear for you? I can explain.

Thanks,
Andrejus

pachiappan said...

Hi,
Thanks for your reply.
In your application we have a departments table. When we click on a row and press Edit it navigates to a page where we can edit the department information. How the department id is being bound so that the current current department information is shown for editing?.

If not the step by step by tutorial if you can give some light on the tricky things like this in your forthcoming posts it will really be helpful.

Once again thanks for your reply.

Regards,
Pachiappan.

Andrej Baranovskij said...

Hi Pachiappan,

Your described functionality is handled by ADF automatically. In View form I just dropped Departments data control as ADF table with selection feature. And in Edit form I dropped Departments data control as ADF edit form.

Since two forms are based on the same View object with the same key, there is no need to do any additional coding.

Sure, I will continue blogging on tricky things. You can read my new blog post about ADF Task Flow also - JDeveloper 11g and ADF Task Flow Parameters.

Regards,
Andrejus

Anonymous said...

Hi I do not know if you still read this blog considering the last post was made in 2007 but I have a problem. When I drag and drop the xml flow to my jspx page the little window where I am supposed to click region does not pop up. Instead it just opens up the xml (flow) page in the designer. Any light you can shed on the matter would be greatly appreciated.

Andrej Baranovskij said...

Do you have task flow with fragments? If it is with pages, then it will not allow to create region.

Andrejus

Anonymous said...

Haha a Timo just asked me the same thing on the OTM forums, it is definetly with page fragments, I was following a tutorial, here is the link

http://www.oracle.com/technology/obe/obe11jdev/ps1/ria_application/developriaapplication_long.htm

And I am almost at the end but cannot drag and drop the flow.

I am glad you still follow the blog

Andrej Baranovskij said...

Of course I'm following, its my blog at the end :)

Just play with JDev, it should allow you to drag and drop. I'm creating regions 10 times per day, so it works for sure :)

Andrejus

Anonymous said...

At first I thought that maybe the problem was with the latest version of oracle that there was some other way to do it. But I am telling you I tried drag and dropping it so many times but when i drop the flow that is the .xml file It just opens it up in a new tab like I want to edit it. But when I put in the .jsff file (which I am not supposed to do according to the tutorial) It does create some forms and stuff in the page. The only problem then is that the page will not run, it opens a blank page and nothing ever loads

Anonymous said...

Hi Andrejus,

I tried to implement same as that of your application.But when we click on a row and press Edit it navigates to a page where we can edit the department information.But in my app the binding between the department ID is not happening and bcoz of that current department information is not shown for editing.

Anonymous said...

Hi Andrejus,

if you still read this blog considering the last post was made in 2010 but I have a problem. I have a jspx page which has been developed based on a template (which contains six facets in 3 layers (top layer - header.jsff, middle layer (2 jsff files) and last layer (3 jsff files)). I have created a task-flow (with fragments) and have rendered it as a region in one of the section of middle layer. I'm loading the fragments dynamically using the navigation rules which i have mentioned in task-flow. The problwm which i'm facing here is, whet ever the fragmnts i'm loading dynamically in that section (where i have added the task-flow as region), i'm able to load the fragments succesfully with out any problem. But when i try to call the navigation rule from header.jsff (which was created as part of template), it is not loading the respective fragment. Please provide some help or solution in this regard. I have done lot of RnD and could not able to come up with a solution. help is highly appreciated.

Andrej Baranovskij said...

Hi,

You have menu component inside header region fragment? It sounds like you would need to use Contextual Events for refresh between regions.

I would not recommend to make it so complex, may be you can merge menu region inside.

Andrejus