Showing posts with label popup. Show all posts
Showing posts with label popup. Show all posts

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.

mainFgmt.jsff

mainFgmt.jsff
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.

adfPopupUtils.js

adfPopupUtils.js
Javascript file to handle the call to the serverListener.

FormContentPopupVb.java


FormContentPopupVb.java
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)

formContentPopup.jsff
formContentPopup.jsff
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.

ReturnHandlerBb.java

ReturnHandlerBb.java
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. 

PopupUtil.java

PopupUtil.java
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.
Cool!

Thursday, June 2, 2011

How to close a TaskFlow Popup Launched Using an af:Popup

Been awhile since I've posted something, so I decided to make a quick and easy hint in ADF.

TaskFlows can be launched as a Popup in a couple of ways in ADF. The most common, I think, is through a taskflow control-case with the following settings:



Then there is the obvious, region in a popup where we drop a fragment taskflow directly inside a popup. I'll show the two common case using a direct popup and a dialog.



The limitation of using it as a direct region though is that the close button is outside the controls of the taskflow, basically, the taskflow itself does not call the close unlike the use of an inline popup as described in the first example. So what happens if we just call the taskflow return from the taskflow? As described in F. Nimphius Fusion Dev Guide, the taskflow itself will close thus closing the binding itself. Here's an example.

Before

After
And forevermore it will remain close unfortunately. Now, to get around this we're going to have the taskflow itself handle situations where it will close the popup without calling the return. To do this, we'll basically retrieve the parent'most component until it is a RichPopup and just call the popup.hide() from there on. So lets go back to coding.

For the fragment, we'll have the return button but this time, it will call an actionListener instead of the controlcase for the return.




Presto. Hope that helps.

Monday, February 7, 2011

Popup from Popup

There are many ways on how to launch a popup from a popup, and I'm going to demonstrate here a "backingBean-based" of launching this.

So why go programmatic? The reason for this is because most of the time, I would prefer launching one popup at a time, meaning  that when I call the second popup, I first make sure to close the current popup.

So a straight forward sample in launching the popup declaratively looks like this.





As you might already know, this is achieved by simply calling af:showPopupBehavior.

Now let's go for the programmatic approach in making sure we first close the current popup before launching a 2nd one. As I have already mentioned, there are different ways of achieving this without binding your popup to a bean by using javascript for example (see Invoke popup from a popup by Luc Bors ).





Cheers.