Thursday, June 26, 2008

How To Call Remote Task Flow in JDeveloper 11g

After my last week presentation on ODTUG Kaleidoscope'08 - Development with Oracle JDeveloper/ADF 11g Reusing 10g Best Practices, I was discussing with a guy from auditory and he have talked to me about problems with remote task flow invocation in JDeveloper 11g. So, in this post I will cover this topic. Generally speaking, possibility to call remote task flow is new feature in JDeveloper 11g and there are still problems in Technology Preview 4 in this area. You can refer to OTN Forum post - TP4 error with calling remote taskflow. Actually, currently it works, but only when calling remote task flow directly with complete URL. In my sample application I have implemented this case.

You can download two parts - JobsLocal.zip and JobsRemote.zip. Those two parts are completely separate applications, however from JobsLocal I'm calling remote task flow available in JobsRemote application. Implemented functionality - in JobsLocal user can select Job from a table and pass selected Job key to remote application, where master-detail form for Job and Employees is opened according to passed key value. Both applications are implemented based on HR schema from Oracle XE database.

JobsRemote application contains bounded task flow - this task flow is called from JobsLocal:


You can notice back control flow case pointing to URL View activity. This activity is used when going back from Remote application - in this case I'm going back by calling jobs page from Local application by URL:


If you will run this sample on your local computer, make sure that you are using correct URL.

Task flow in JobsRemote application accepts parameter for setCurrentRowWithKeyValue action:


When task flow in Remote application is defined and components on the page are created, its time to create deployment profile - ADF Library JAR File. We will pack our Remote application as JAR file in order to use defined task flow in Local application:


In order to create JAR after deployment profile is set, just right-click on ViewController and choose Deploy -> Deployment Profile Name -> to ADF Library:


Now its time for JobsLocal application, at first add generated JAR library to Application Resources by selecting New Connection -> File System... in JDeveloper 11g section called Application Resources:


In opened dialog - Create File System Connection, provide Connection Name and Directory Path. Optionally you can Test connection and if Status is positive press OK button:


Library with JobsRemote application task flow is added and you can drag and drop it to the task flow in JobsLocal:


When you will drag and drop it, JDeveloper 11g will create it as Task Flow Call activity:


Only one thing you will need to do is to provide URL for remote application. In our case, I'm constructing URL dynamically in Backing bean method (make sure it is correct in your environment):


getRemoteTaskFlowURL() method retrieves selected row key from Jobs table and adds it as a parameter to remote task flow URL. I'm using the same name for parameter as it is defined in task flow from JobsRemote application.

You can run both applications in parallel directly from JDeveloper 11g, just you will need to use Integrated OC4J option, by default Embedded OC4J option is used. You can switch just by opening Tools -> Java EE Runtime Preferences.

At first, you will need to run bounded task flow from JobsRemote application, since this task flow is called from JobsLocal.

When JobsRemote will be up and running, run jobs.jspx page available in JobsLocal application, you will get similar screen:


In my case I have selected row with JobId = SA_MAN. When Edit Job button is pressed, it navigates to task flow available in remote application - JobsRemote by passing selected job key value:


Remote application is opened with correct data for provided key. You can edit and save data from this screen. Button - Back, through URL call will navigate to original jobs.jspx page in JobsLocal application:

15 comments:

javabuddy said...

I am stuck on condition if the included task flow has fragments or not.

I have a task flow that is built with fragments.

I need to consume the above task flow in my app(external) inside a jspx page(not a page fragment)

Andrejus Baranovskis said...

Its quite easy, you just need to deploy your ADF Task Flow to ADF JAR and reuse it as a library in your external application.

Regards,
Andrejus

Anonymous said...

I did as you said, but now I am getting the following error.

"TaskFlow Call Activity cannot invoke remote taskflow inside a Region"

Julio Araujo said...

Hi Andrejus,

I can't create connection on application resources like your example, no show in the list "File System".

Some advice i would apreciate it.

thanks.

Andrejus Baranovskis said...

Which version of JDev you are using, it must be there for sure.

Andrejus

Julio Araujo said...

Hi Andrejus,

The version it's 11.1.1.2.0

thanks.

Julio Araujo said...

Hi Andrejus,

Do you have any comments or advice ?

regards

j.araujo

Andrejus Baranovskis said...

No actually, it should be available this wizard in all versions of JDev.

May be you need to go to JDev menu 'View' and select 'Resource Palette'

Andrejus

Prabhanjan said...

Andrejus,

what about propagating security if remote task flow is deployed in different servers?

Thanks,
Prabhanjan

Andrejus Baranovskis said...

It will not work out of the box ADF Security.

Andrejus

Narendra Chowdary said...

Hi Andrejus,
This is Narendra.
when i'm trying to run bounded task flow from JobsRemote application i'm getting a error msg "View row with key oracle.jbo.Key[ ] is not found in JobsView1Iterator", after that when i'm trying to run run jobs.jspx page available in JobsLocal application then i'm getting error as "oracle.jbo.JboException: JBO-29114 ADFContext is not setup to process messages for this exception. Use the exception stack trace and error code to investigate the root cause of this exception. Root cause error code is JBO-34010".

I tired alot to resolve it, but i'm not finding a way to execute it.

Anonymous said...

Hi Andrejus,
Is there a way to invoke a remote taskflow without adding it as a library to calling application .Actaully my remote taskflow is not available in public jars.

Andrejus Baranovskis said...

Yes, you can call it without having added as a JAR. Here I had it added only for convenience, to be able to drag and drop on the diagram, later you can remove it.

Andrejus

garg said...

Can we call remote task flow( which uses fragements) in other applictaion under Tab.

Anonymous said...

Hi Andrejus
You sample app works ok with JDev IDE but when I deploy the application it does not redirect either remote1 or remote2 when click on first/second button

Is there any other configuration which is required to work your sample after deployment?

Thanks
Jalil