This discussion is archived
11 Replies Latest reply: Aug 2, 2010 5:58 PM by Chris Muir RSS

UI Shell - how to allow ADF Library Bounded Task Flow to close itself

Chris Muir Employee ACE
Currently Being Moderated
Hi Richard

Further to my other post, we're having lots of fun with the UI Shell, it's making mockups very easy.

Question for you though based around the functionality defined in the UI Shell whitepaper. Say we've created our UI Shell application, and rather than wanting to create the bounded task flows in the app (ie.first, second, third), we create them as standalone bounded task flows deployed to ADF Libraries, and imported into our app separately.

In the UI Shell examples bounded task flows are opened & closed via the UI Shell's own components (say the navigation page items or toolbar buttons), that call the methods in the Launcher bean (_launchActivity & closeCurrentActivity). It's fairly simple to rewrite the launcher helper methods in the launcher bean to call an imported ADF Library bounded task flow to open it as an activity, just referencing the correct task-flow.xml file.

However as you know a bounded task flow has a "Default Activity" entry point and one or more "Task Flow Return" exit points. What I haven't been able to work out is how when the bounded task flow exits via a task flow return, can we call the closeCurrentActivity method in the Launcher bean? The UI Shell code examples demonstrate closing a bounded task flow by menu options/or similar outside the bounded task flow in the UI Shell, but it would seem reasonable if the bounded task flow exited via a "Task Flow Return" we should be also able to close the activity tab too.

(....and as extension, before we even do that potentially call the checkState/isDirty() method to stop the user closing the activity too, but again driven by the bounded task flow attempting to exit).

I could imagine inserting code into the bounded task flow finalizer to close the activity tab, but this pushes the UI Shell tab activity management logic into our standalone ADF Library bounded task flows which isn't ideal, especially if we want to later reuse them in another app which doesn't use the UI Shell.

Any suggestions welcome.

Thanks & regards,

CM.
  • 1. Re: UI Shell - how to allow ADF Library Bounded Task Flow to close itself
    Chris Muir Employee ACE
    Currently Being Moderated
    After some research, scratching my head, trying several things I came up with this solution.

    In the page template define a regionNavigationListener for each region. ie:
    <af:region value="#{viewScope.tabContext.tabs[0].binding.regionModel}"
        id="pt_region0" rendered="#{viewScope.tabContext.selectedTabIndex == 0}"
        regionNavigationListener="#{viewScope.tabContext.myRegionNavigationListener}"/>
    The RegionNavigationListener is called everytime there is a page fragment change in the bounded task flow embedded within the region. The RegionNavigationEvent passed to the listener has methods getOldViewId() and getNewViewId() to retrieve the previous page fragment name and the new page fragment's name. It appears the getNewViewId() is null if the bounded task flow closes. This gives us the hook to close the UI Shell template, as follows:
    public void myRegionNavigationListener(RegionNavigationEvent regionNavigationEvent) {
         String newViewId = regionNavigationEvent.getNewViewId();
         if (newViewId == null) {
              removeTab(_selectedTabIndex);
         }
    }
    Note this method is placed in our TabContext class.

    I did try investigating if the bounded task flow can raise a contextual event on exit which the UI Shell could use to trigger code to close the activity tab, but couldn't see what to define the contextual event against in the bounded task flow. Maybe somebody with experience in the latest contextual event facilities in 11gPS1 can comment.

    CM.
  • 2. Re: UI Shell - how to allow ADF Library Bounded Task Flow to close itself
    Chris Muir Employee ACE
    Currently Being Moderated
    I spoke to soon. It appears the 2nd time the same activity/task flow is opened, then closed, the regionNavigationListener isn't called.

    Dumdedum. Trying something else now.

    CM.
  • 3. Re: UI Shell - how to allow ADF Library Bounded Task Flow to close itself
    Chris Muir Employee ACE
    Currently Being Moderated
    I spoke to soon x 2. Looks like it is working, I hadn't refreshed an ADF Library correctly.

    CM.
  • 4. Re: UI Shell - how to allow ADF Library Bounded Task Flow to close itself
    Chris Muir Employee ACE
    Currently Being Moderated
    And we're back again.... what's a couple months between friends?

    So it turns out after testing our app (d@mn, so close) that we've hit a bug with this approach.

    Our current app allows one BTF to be open in the UI Shell at any one time. Our menu options automatically open one BTF at a time by the user (max one open), and close the previous BTF. However we have some "special" BTFs that require the user to explicitly close the BTF, which in turn makes use of the regionNavigationListener solution I described earlier in this post.

    However we discovered a bug when we do a complete cycle of the 15 embedded regions within the UI Shell.

    Say we:

    1) Open a normal BTF in region 0
    2) Open another normal BTF in region 1 (our solution automatically closes the previous BTF)
    3) We then open another BTF (again the previous BTF is closed) in region 2, yet this a "special" BTF requiring the user explicitly to close it. Upon the user closing the BTF - this results in the regionNavigationListener being called and the removeTab() method called to close down the BTF in the UI Shell
    4) The user then open/closes multiple normal BTFs, one by one, rotating through regions 3, 4, 5 .... eventually back to 1 again
    5) Then the bug occurs - on opening any BTF back in region 2 (as part of the complete cycle of all regions), the tab for the region 2 opens, correct title, and via debugging the Tab.class has all the right settings including taskFlowId, but the tab is incorrectly empty

    doh!

    I've managed to track a symptom of the problem down that may explain what's happening.

    Each time a tab is rendered with a BTF, the Tab classes getBinding() method returns a reference to the binding required for the current BTF. However for some reason on the complete cycle, for "r2" it returns the binding for the previously user-closed BTF from step 3 above, even though we called the TabContext.removeTab() method.

    What I haven't been able to work out is how the bindings get turned on/off dynamically for each BTF being invoked. Presumably for some reason on step 3, the BTF's bindings aren't being correctly removed from r2 even though we called TabContext.removeTab().

    If anybody has any brain waves about what's going on and how to fix this problem, your help appreciated.

    Regards,

    CM.
  • 5. Re: UI Shell - how to allow ADF Library Bounded Task Flow to close itself
    Chris Muir Employee ACE
    Currently Being Moderated
    And to follow up this thread several months later, to ensure nobody is mislead. We've recently built a brand new application based on the latest UI Shell and the issue of BTF's closing themselves in the UI Shell is a none issue in the latest release. Why the problem occurs in our original application eludes us, of which we've a coded solution, but is something we don't need to worry about in our new application.

    CM.
  • 6. Re: UI Shell - how to allow ADF Library Bounded Task Flow to close itself
    amseth Pro
    Currently Being Moderated
    Chris,

    I am using UI shell and many BTF in it. Currently tabs are not getting removed when TF's are returned.
    As a user what do I need to do to get that working ?

    Thanks.
  • 7. Re: UI Shell - how to allow ADF Library Bounded Task Flow to close itself
    Chris Muir Employee ACE
    Currently Being Moderated
    Before I answer that, can you verify:

    1) which version of JDev you're using?
    2) which version of the UI Shell you're using?

    CM.
  • 8. Re: UI Shell - how to allow ADF Library Bounded Task Flow to close itself
    amseth Pro
    Currently Being Moderated
    JDev: 11.1.1.2.0 Build JDEVADF_11.1.1.2.0_GENERIC_091029.2229.5536
    UI Shell: 1.02

    Thanks
  • 9. Re: UI Shell - how to allow ADF Library Bounded Task Flow to close itself
    Chris Muir Employee ACE
    Currently Being Moderated
    Sorry for the slow reply.

    Hmmm, I was hoping I'd discover you were still using the original UI Shell version, as that would coordinate with when we last saw the issue.

    Is there any other characteristics of your BTFs that may be unusual? Do your BTFs take no parameters? Do you use the ShellLauncher approach to opening the BTFs or a different mechanism?

    As for the solution I came up with, I'll post the basics tomorrow when I return to work.

    There's something else you can check. As you may know the ADF UI Shell supports up to 15 tabs. If you open and close tabs, it slowly rotates each tab position from 0...14, then back to 0 again. Presumably at this point when your self-closing-BTFs don't close, you simply close the tab using the red X button provided. Have you ever tried opening and closing that BTF over 15 times to see if there is any strange behaviour?

    We had a scenario where on re-using one of the slots in the UI Shell, or in other words in rotating through all the UI Shell 15 tab spots, we discovered that on re-using a tab spot that had had a self-closing-BTF previously, then the new BTF refused to open correctly in the re-used tab spot (if that makes sense).

    CM.
  • 10. Re: UI Shell - how to allow ADF Library Bounded Task Flow to close itself
    amseth Pro
    Currently Being Moderated
    Thanks for reply Chris.
    I am trying to follow the UI shell forum very closely as we are using this template in all our landing pages and its important as most of the components in our application integrates here.
    To start with we do have some customization on UI shell template by adding style classes to the components used, jared and used as template in application(I followed one of the blogs from pino)
    Apart from that I dont see any unusual behavior.

    I am using TF parameters and passing them using ParameterMap. It works fine. Launching Tabs through _launchActivity method as described.
    We don't have a scenario where user can utilize all 15 Tabs at same time. We limit him by opening only one instance of an activity say 'create'.
    We limit to open more than one create at any given time. If user tries to open another create, we warn and close the current create tab and
    launch new tab.[we did this to prevent user from getting lost in so many tabs and limiting no. of open txns at any given point of time.]
    But I can give a shot to see what happens when all 15 tabs/regions are used and opening new one by closing one at 0 and opening a new one.

    Thanks.
  • 11. Re: UI Shell - how to allow ADF Library Bounded Task Flow to close itself
    Chris Muir Employee ACE
    Currently Being Moderated
    >
    We don't have a scenario where user can utilize all 15 Tabs at same time. We limit him by opening only one instance of an activity say 'create'.
    We limit to open more than one create at any given time. If user tries to open another create, we warn and close the current create tab and
    launch new tab.
    >

    Ah, there's a similarity. For whatever business reason, we built something similar via logic in the ShellLauncher. Hmmm, I wonder what the connection is?

    Anway, before I go into our solution for fixing the self closing tab issue which is elaborate (read: complicated), in the new UI Shell 1.02 version you're aware that the TabContext class has a new method setMainContent(). The main content method (from the TabContext Javadoc) says:

    >
    This class supports two modes for the tab shell:

    1. Dynamic set of tabs, each represented by a taskflow content page.

    2. Single content area, that is also backed by a taskflow content page, and can be switched on demand.

    These two modes are mutually exclusive, and cannot be used with one another.
    >

    Maybe "2" has better handling for self closing BTFs? Worth a try on your part.

    CM.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points