0
votes

We are currently facing one problem in our portlet-environment using JSF2.

The application is creating dynamic portal-pages for the actual user session...think of it as Eclipse editor-views where the user can edit entities. So for now I call the dynamic-views editors :-)

The problem we are facing now, is following. The user navigates to a editor and works on the portlet(s). The displayed views in each portlet change over time of course. Now he wants to have a look on another entity which is displayed in another editor. But when he navigates back to the first editor, the state of portlets changes back to the default views.

In the portlet-world each portlet each portlet gets the view it should display via a parameter which is stored in the PortletSession and I can easily change that parameter as well. I know that this parameter is causing the trouble because when the changes the editors, the portlets will always check this parameter to decide which view to show.

request.getPortletSession().setAttribute("com.ibm.faces.portlet.page.view", "/MyPage.xhtml");

My idea was, to somehow add a callback to each JSF-navigation which will set this parameter to the view the navigation is going to display (possibly including view-params). Is it possible to have a standard callback? If not, would be possible to execute some kind of EL in the navigation-rule that will set this parameter?

1

1 Answers

1
votes

somehow add a callback to each JSF-navigation

You could perform the job in a custom ConfigurableNavigationHandler. Here's a kickoff example:

public class MyNavigationHandler extends ConfigurableNavigationHandler {

    private NavigationHandler parent;

    public MyNavigationHandler(NavigationHandler parent) {
        this.parent = parent;
    }

    @Override
    public void handleNavigation(FacesContext context, String from, String outcome) {

        // TODO: Do your job here. 

        // Keep the following line untouched. This will perform the actual navigation.
        parent.handleNavigation(context, from, outcome);        
    }

    @Override
    public NavigationCase getNavigationCase(FacesContext context, String fromAction, String outcome) {
        return (parent instanceof ConfigurableNavigationHandler)
            ? ((ConfigurableNavigationHandler) parent).getNavigationCase(context, fromAction, outcome)
            : null;
    }

    @Override
    public Map<String, Set<NavigationCase>> getNavigationCases() {
        return (parent instanceof ConfigurableNavigationHandler)
            ? ((ConfigurableNavigationHandler) parent).getNavigationCases()
            : null;
    }

}

To get it to run, register it as follows in faces-config.xml:

<application>
    <navigation-handler>com.example.MyNavigationHandler</navigation-handler>
</application>