You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Safurudin Mahic <sa...@stud.aitel.hist.no> on 2007/07/02 19:45:31 UTC

NavigationMenu and active state across

I have a sample navigationmenu implemented on my page;

-----------------------------------------------------------------
                <t:panelNavigation2 id="nav1" layout="list" 
itemClass="mypage"
                    activeItemClass="selected" openItemClass="selected">
                    <t:navigationMenuItems 
value="#{navMenu.navigationItems}" />
                </t:panelNavigation2>

and the backing bean

    public NavigationMenu() {
        navigationItems = new ArrayList<NavigationMenuItem>();
        navigationItems.add(new NavigationMenuItem("Dashboard", 
"dashboard"));
        navigationItems.add(new NavigationMenuItem("Customers", 
"customers"));
        navigationItems.add(new NavigationMenuItem("Groups", "groups"));
        for (NavigationMenuItem n : navigationItems) {
            n.setActionListener("#{navMenu.actionListener}");
        }
    }

    public List getNavigationItems() {
        return navigationItems;
    }


    public void actionListener(ActionEvent event) {
        if (event.getComponent() instanceof HtmlCommandNavigationItem) {
            log.info("ActionListener: "
                    + ((HtmlCommandNavigationItem) event.getComponent())
                            .getValue());
            selectedItem = (HtmlCommandNavigationItem) event.getComponent();
            selectedItem.setActive(true);
        }
    }
--------------------------------------------------------

My problem is when I want to invoke some of the actions on the 
navigation menu -
If I define the navigationrule for the "dashboard" action without redirect,
    <navigation-rule>
        <navigation-case>
            <from-outcome>dashboard</from-outcome>
            <to-view-id>/dashboard.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

the panelnavigation correctly renders the selected active item on the menu.

But if I put redirect in the navigationrules, the active item
is not rendered. How would I get the active navigation item to be 
rendered "active" across redirects? Is this the same problem
as the <h:message> not being able to render messages across redirects?

Thanks,
Safurudin