myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Myfaces Wiki] Update of "Dynamic Menus with JSCookMenu" by BrunoAranda
Date Thu, 22 Sep 2005 11:08:29 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by BrunoAranda:

New page:
Many people ask in the user list how to create a !JsCookMenu dynamically. This is the way:

1. Create a backing bean (in this example, named 'dynMenu') with the code to generate a !NavigationMenuItem[],
like this:


import org.apache.myfaces.custom.navmenu.NavigationMenuItem;

public class DynamicMenuTest {

    private NavigationMenuItem[] navItems;

    public DynamicMenuTest() {
        // children for item 2
        NavigationMenuItem[] subItems = new NavigationMenuItem[2];
        subItems[0] = new NavigationMenuItem("Subitem 2_1 Label","action2_1", "iconUrl", false);
        subItems[1] = new NavigationMenuItem("Subitem 2_2 Label","action2_2", "iconUrl", false);
        // item 2
        NavigationMenuItem itemWithChildren = new NavigationMenuItem("Item 2 Label", "action2",
"iconUrl", false);
        // root items
        navItems = new NavigationMenuItem[3];
        navItems[0] = new NavigationMenuItem("Item 1 Label","action1", "iconUrl", false);
        navItems[1] = itemWithChildren;
        navItems[2] = new NavigationMenuItem("Item 3 Label","action3", "iconUrl", false);
    public NavigationMenuItem[] getNavItems() {
        return navItems;

    public void setNavItems(NavigationMenuItem[] navItems) {
        this.navItems = navItems;



2. Then, in your jsp use this code to call to the backing bean and to the generated menu:


   <x:jscookMenu layout="hbr" theme="ThemeOffice">
                <%/* Availaible jscookMenu themes: ThemeIE, ThemeMiniBlack,ThemeOffice,
             Availaible jscookMenu layout: hbr, hbl, hur, hul, vbr,vbl, vur, vul
             respect to Heng Yuan
                <x:navigationMenuItems value="#{dynMenu.navItems}" />


View raw message