Then, one thing you could do is to create a class that extends
MethodBinding and implements StateHolder with a constructor with your
value as a parameter, and overriding then the invoke method. If you
have problems with this, take a look to the source of
org.apache.myfaces.el.SimpleMethodBinding in the shared package of the
myfaces sources.

Then you can set the action in your NavigationMenuItem like this:

MyMethodBinding mb = new MyMethodBinding(value);
navItem.setAction(mb);

Regards,

Bruno

2005/6/9, Klug, Boris <[EMAIL PROTECTED]>:
> Hi!
> 
> yes, this helped a lot. Now I can build my menu dynamically. The only problem
> that I have is that I want to call the same action in a bean (#{bean.action})
> from each menu item of a menu and the action should figure out which menu item
> was choosen.
> I cant set an action listener which would get the ActionEvent with e.g. a 
> value.
> 
> So how do I do this?
> 
> --
> Boris Klug
> 
> Zitat von Bruno Aranda <[EMAIL PROTECTED]>:
> 
> > Hi Boris, this can be achieved declaring NavigationMenuItem components
> > dynamically in a backing bean. The JSP code could be something like
> > this:
> >
> > [CODE
> >
> > <x:jscookMenu layout="hbr" theme="ThemeOffice">
> >               <%/* Availaible jscookMenu themes: ThemeIE, ThemeMiniBlack,
> > ThemeOffice, ThemePanel
> >              Availaible jscookMenu layout: hbr, hbl, hur, hul, vbr,
> > vbl, vur, vul
> >              respect to Heng Yuan http://www.cs.ucla.edu/~heng/JSCookMenu
> >         */%>
> >               <x:navigationMenuItems value="#{dynMenu.navItems}" />
> >       </x:jscookMenu>
> >
> > [/CODE]
> >
> > Then I have to create an array of NavigationMenuItems (call
> > 'navItems') in my backing bean 'dynMenu'.
> > The code for the manage bean could be something like this:
> >
> > [CODE]
> >
> > 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);
> >         itemWithChildren.setNavigationMenuItems(subItems);
> >
> >         // 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;
> >     }
> >
> > }
> >
> > [/CODE]
> >
> > Hope this helps,
> >
> > Bruno
> >
> > 2005/6/8, Klug, Boris <[EMAIL PROTECTED]>:
> > > Hi!
> > >
> > > we use the great jscookmenu component. Most of the menus are static but 
> > > one
> > menu
> > > should contain one or more items, depending on the current page displayed.
> > How
> > > can this be achived? Any samples?
> > >
> > > Thanks for your help
> > >
> > > --
> > > Boris Klug, Germany
> > >
> >
> 
>

Reply via email to