I have one menu item in menu bar. This menu item has other menu items (sub-menu items). I need that when user clicks on this menu item, sub-menu items will be displayed and to main menu item will be added some style. I tried:
@Override
public void menuSelected(MenuItem selectedItem) {
menuItem.setStyleName("mystyle");
}
};
menuItem.setCommand(cmd);
[/code]When I click on menu item the style is changing, but sub-menu items are not displayed. When I remove command, sub-menu items are displayed. How can I reach both displaying sub-menu items as well as adding style name?
I’m using Vaadin 6.
Have you tried addStyleName instead of setStyleName, I assume you want to just add some accent for selected menu. I suspect when you use setStyleName, you remove some important style regarding your theme, and hence sub-menu not showing.
You are correct. This issue has popped up also before. I think this one is worth of trying, So instead of adding stylename, use the stylename in your theme css that is set by Vaadin 6 automatically.