Friday, October 5, 2012

Oracle ADF - Using Region Navigation Listener in af:region

Greetings,

Its been long that i have posted something related to ADF. Thanks to my visitors who ask questions to keep me alive.

One reader shared a use case with me as follows

"We have a requirement to collapse a panel in Panel splitter for specific activity in a region"

The answer for that is use Region Listener in af:region component.

The Region Listener have a RegionNavigationEvent argument which can provide the current view in a af:region based on that you can conditionally collapse or expand panel

Example: Download complete example

In my bounded task flow i got 3 views, view 1-3 respectively as shown in the slide.





I have home page with Panel splitter and af:region in facet 2



My use case is to collapse left panel when user navigates to view 2 in a region.





I have a Region Listener as follows



I have panel splitter binding in the bean 



The Region Navigation Listener code is as follows


public class RegionNavigationListener {
    private RichPanelSplitter myPanel;

    public RegionNavigationListener() {
    }

    public void onRegionNavigated(RegionNavigationEvent region) {
        String viewId = region.getNewViewId();        
        
        if (viewId.equalsIgnoreCase("/region-flow-definition/view2")) {
            doCollapsePanel(myPanel);
        }
        else {
            doExpandPanel(myPanel);
        }
    }
    
    private void doCollapsePanel(RichPanelSplitter panel){    
        panel.setCollapsed(true);
        AdfFacesContext.getCurrentInstance().addPartialTarget(panel);  
    }
    
    private void doExpandPanel(RichPanelSplitter panel){    
        panel.setCollapsed(false);
        AdfFacesContext.getCurrentInstance().addPartialTarget(panel);  
    }
    

    public void setMyPanel(RichPanelSplitter myPanel) {
        this.myPanel = myPanel;
    }

    public RichPanelSplitter getMyPanel() {
        return myPanel;
    }
}


Hope you like it 

Follow me on twitter and happy Jdeveloping,
Zeeshan Baig 








6 comments:

  1. I have an issue, where the popup does not load its contents for the first time, i.e its not able to navigate to the region for the first time, but from second time, it navigates and popup shows up with its contents. I am using regionNavigationListener to navigate to another region inside the popup. Do u have any idea about it

    ReplyDelete
    Replies
    1. Hi,

      Best is to use debugger and log files, check if you find anything there. Also set the immediate property to true on action button it might skip any validation issues in the background.

      Zeeshan

      Delete