YuiMenuBarItem firstMenu = mb.addMenu("First Menu");
// 1st Menu
AbstractYuiMenuItem mi = null;
YuiMenu subMenu = null;
subMenu = firstMenu.newSubMenu("mb_firstMenu");
subMenu.addMenuItem(new TestAction("M1 : L1"));
subMenu.addMenuItem(new TestAction("M1 : L2"));
mi = subMenu.addMenuItem(new TestAction("M1 : L3"));
subMenu.addMenuItem(new TestAction("M1 : L4"));
subMenu.addMenuItem(new TestAction("M1 : L5"));
subMenu = mi.newSubMenu("subMenu1");
subMenu.addMenuItem(new TestAction("Label 1"));
subMenu.addMenuItem(new TestAction("Label 2"));
// 2nd Menu
YuiMenuBarItem secondMenu = mb.addMenu(new TestAction("Second Menu"));
final YuiMenu subMenu2 = secondMenu.newSubMenu("mb_secondMenu");
subMenu2.setOutputMarkupId(true);
subMenu2.addMenuItem(new TestAction("M2 : L1"));
final YuiMenuItem m2L2 = new YuiMenuItem(new TestAction("M2 : L2"));
subMenu2.addMenuItem(m2L2);
subMenu2.addMenuItem(new AjaxLinkAction("M2 : L3 (Ajax) - toggles M2 : L2")
{
@Override
public void onClick(AjaxRequestTarget target)
{
MenuBar2Page.this.info(getName().getObject());
m2L2.setDisabled(!m2L2.isDisabled());
m2L2.setChecked(!m2L2.isDisabled());
m2L2.setSelected(m2L2.isChecked());
target.addComponent(feedback);
target.addComponent(mb);
}
});
subMenu2.addMenuItem(new TestAction("M2 : L4"));
subMenu2.addMenuItem(new TestAction("M2 : L5"));
// 3rd Menu
mb.addMenu(new TestAction("Third Menu"));
add(mb);