Wednesday, March 13, 2013

Reusable ADF Region with Dialog Framework

This post is about reusable ADF region and its usage from ADF Dialog Framework. If we have ADF Task Flow with fragments and want to use Dialog Framework, we need to create intermediate ADF Task Flow with pages and include our reusable region there - this will allow to load ADF Dialog from the fragment (dialog is always running in ADF page). I will describe in this post how to pass data from/to ADF region included into ADF Dialog to the calling fragment.

There is main ADF Task Flow in the sample - empls-flow (download sample application ReusableDialogRegionApp.zip):


This task flow is configured to call intermediate ADF Task Flow with wrapper page. We are passing  and getting parameters to/from the dialog:


Dialog is opened from the button in the main employees fragment:


Button is configured to open dialog:


There is dialog listener defined for this button, it receives return value. Alternatively we can get return value from the dialog return parameter directly:


Intermediate ADF task flow (which actually implements ADF dialog), contains a page and return activity. This page is only a wrapper, it includes reusable ADF region:


Intermediate ADF task flow with wrapper page defines input and output parameters:


Wrapper page contains Close button, this button sets return value, it retrieves return value from the bindings. Because Data Control is shared between reusable ADF region and intermediate ADF task flow with wrapper page, we can access bindings from ADF region and return it from the wrapper page. You can see that this page includes our reusable ADF region:


Here is binding definition for the attribute in the page definition for wrapper page:


And the last bit - ADF reusable region, JSF fragment view:


Bindings for ADF reusable region, you can see where CountryId attribute value is set. We are getting the same value in dialog wrapper page through shared Data Control:


I should mention one important thing - intermediate ADF dialog task flow is configured to run in isolated scope. This is important and allows to reset reusable ADF region in the dialog always to its initial state on opening:


Countries region is loaded and DepartmentId value is passed into:


Selected value is returned back:


The same reusable region is opened from another fragment - region state is reset, user can select value and return it:

17 comments:

M.Ahmed said...

Hi Andrejus,
I need to make something like this but I've a problem that I need this popup to open without firing the validation in the page.
For Example I need to use popup like this to insert value in a field and I want the validation is not fired.
if for example Employee ID is not entered the validation will fire.

Andrejus Baranovskis said...

There is a way - we have implemented it in one of the projects. I plan to blog sample app.

Andrejus

Anirban Mukherjee said...

Andrejus,

I tried out your solution in a sample application. I am getting a "ADF_FACES-60101:HTTP Error Status Code: 404" error every time I am accessing the bounded taskflow from the button.
Please note that the jsf page I have used for the TF is under public_html folder and not under WEB-INF.

Am I missing some configuration in the TF call?

Best Regards,
Anirban Mukherjee

M.Ahmed said...

Thanks Andrejus,
I'm waiting :)

Andrejus Baranovskis said...

Hi,

Yes - you should compare one by one differences with my sample app. There can be different reasons for the error you are getting. You can enable ADF log diagnostics FINEST level for ADF Controller - it will show whats wrong.

Andrejus

Mahmoud Sawalha said...

I get the same error "HTTP Error Status Code: 404" only when I deploy the application in a production environment.

I tried the same technique with JSPX -not JSF-; It works!!! in the embedded weblogic and in the production environment.

Andrejus Baranovskis said...

This means you are missing something. How come my sample app works with JSF Facelets then? :)

Andrejus

Mohammed Tanveer said...

Hi andrejus

Will the pop up share the data controls of the caller jsff?

Andrejus Baranovskis said...

It runs in isolated scope - this is whole point of this sample :)

Andrejus

meemou said...

Andrejus

We have the events getting published in a JDEV project and they have to be subscribed by a page in another JDEV project. The jdev project is not able to list out the events/handlers of the region for event mapping. The project which has the region has been added in the classpath of the referring project. Is there anything else?

Kerri Harris said...

I need help with the following scenario. I have task flow A calling task flow B. Task flow B is a separate project from task flow A (i.e. task flow b is access using a shared library). Task flow A calls task flow B via a region in a page of task flow A. Task flow B's default activity is a method. If that default method throws an error/exception we don't want the task flow to open and display the page fragment associated with it. Instead we want that error to return to task flow a and display there. Is this possible? I tried this example, and using the ViewPortContext currentViewPort = context.getCurrentViewPort(); as well as the getCurrentRootViewPort() and it knows there is an exception, but it's just a generic exception. It's not the exception thrown in task flow b. If the default method does not throw an exception then we want the page fragment to display and continue loading the task flow. The problem is that we can't have task flow b open and popup the error because the page would just be a blank page with a popup error which isn't the prettiest.

John Glista said...

How did you get the popup to display without the close button at the top right of the popup? I'm trying to display a confirmation for the user when the attempt to press the "close" button. This can easily be done through the task flow handling, but I can't find a way to control what happens prior to closing the popup if the "X" is clicked. Therefore my solution is to simply remove it, just as it appears in your example. Any ideas? Thanks

Andrejus Baranovskis said...

Hi,

Here you will find the answer: https://blogs.oracle.com/jdevotnharvest/entry/how-to_remove_the_close_icon_from_task_flows_opened_in_dialogs_11114

Regards,
Andrejus

John Glista said...

Thank you, that was very helpful. Although, I wish this wasn't an application-wide setting. This means I have to enable this setting application-wide, then apply the style class for all other popups in the application for which we *do* want to display the "X". Our application has 15+ ADF library jars, including a view project, which all contain many popups, so this may likely not be an option for me.

Andrejus Baranovskis said...

I see, this is never easy :) Try another approach - https://blogs.oracle.com/jdevotnharvest/entry/how-to_hide_the_close_icon_for_task_flows_opened_in_dialogs

Andrejus

Naeem Qasim said...

Great Post it helped me a lot

crossmymind said...

Hello,
Thank you for this post!

I am using Jdeveloper 11.1.2.4.0.

I have tried to reproduce your example, only I have used jsff instead of jsf.

The only problem is that the value for the input parameter was not being displayed on the last taskflow's page.

I hade to change every pageflowscope with request scope for the input parameters, and now it works. But I would like to understand why it worked with request scope, and not pageflowscope.

Also, could you please tell me why you first set request scope, for the infput parameter, in the dialog TF, and for the other parts where input params where needed, you used pageflowscope?

Thank you!