Saturday, July 2, 2011

ADF Region Handled in a RichPopup - Including a Return Value

I used David Giammona's blog about:

So most of the code kind-of goes as what the blog does as well as what Fusion Dev Guide by F.Nimphius on launching a region within popup... or a popup with a region (forgot the topic title).

My project is setup to log on the following areas.
  • Region task flow entry - just so we know that the task flow has started.
  • On popup launch - this is the part that we handle the switch between an empty region to the actual region
  • On regionNavigationEvent - this is where we handle the programmatic handling of closing the popup. I used a java approach in closing the popup oppose to javascript which is published in paper. This is also the place where i handle the response. The reason for this is because a return from the region is tagged as a null viewId so it is the perfect trigger for me to check for the response which the region throws.
  • On popup close - as you probably already know, this is where i handle the switch to an empty region. Also this listener gets triggered on Cancel, Ok and Escape of the popup.
Anyway, i'll start posting codes.


As you can see, I'm directly using showPopupBehavior which means that the popup itself will be rendered directly at the same level as this page. So the popup and the view would pretty much have a handle on the scope which of course from the region, you shouldn't try to cross the scope. Later i'll explain more how I decided to handle the parameter passing without the use of contextualEvent.


Javascript file to handle the call to the serverListener.
This bean (viewScope) handles the dynamic region taskflowId. The switching of taskflowId to/from an empty region. Check for a response which I'll explain more.

FormContent TaskFlow (pageFragment)

This is the fragment as part of the task flow region that is used inside the af:popup. I have an actionListener which not only navigates for return but also configures the response.
This backing bean, as noted will look for the calling popup, search for the region that is directly contained with it (since this is the same region which will handle the regionNavigationEvent), and add an attribute to that component. Yes, there is a potential for this to blowup if the task flow is not used in a popup, but that is why the same utility to retrieve the popup will tell us if this taskflow is being rendered inside one.
Utility class to retrieve the parent popup.

So as you can see based on the code, the flow of the setup goes like this.
  • Link is clicked which triggers ShowPopupBehavior
  • Popup receives the event and launches which triggers the fetchListener
  • FetchListener handles the configuring of the empty to taskflow to our actual taskflow region
  • Region hits an OK or Cancel and triggers the appropriate ActionListener
  • ActionListener looks for the parentPopup and from there, it retrieves the direct region below it.
  • Configure the RichRegion for an extra attribute which in this case we called "Notification".
  • Return is called by the taskFlow.
  • Region in the calling page triggers RegionNavigationHandler.
  • RegionNavigationHandler closes the popup and also check for the response from the taskflow.
  • OnPopup close, the clientScript is triggered which calls our serverListener.
  • ServerListener makes sure that the dynamic region is reset to an emptyTaskflow.

1 comment:

  1. Just to highlight, it is important to change the method signature and implementation of getDynamicTaskFlowId to return a String and skip the TaskFlowId.parse that JDeveloper initially writes for you. TaskFlowId.parse will refuse to allow an empty taskflow id.