I'm starting to use the GWTBoostrap3 and my greatest need is to create a menu that contains submenus, and this menu needs to be dynamic, so need to do in Java. It would be something like Gwt MenuBar
my attempts....
final ListDropDown listDropDown = new ListDropDown();
AnchorButton anchorButton = new AnchorButton(ButtonType.INFO);
anchorButton.setText("btn1");
DropDownMenu dropDownMenu = new DropDownMenu();
AnchorListItem anchorListItemd = new AnchorListItem("Item 1");
dropDownMenu.add(anchorListItemd);
anchorButton.setDataToggle(Toggle.DROPDOWN);
listDropDown.add(anchorButton);
listDropDown.add(dropDownMenu);
final ListDropDown listDropDown2 = new ListDropDown();
final AnchorButton anchorButton2 = new AnchorButton(ButtonType.INFO);
anchorButton2.setText("Item 2");
DropDownMenu dropDownMenu2 = new DropDownMenu();
dropDownMenu2.setStyleName("dropdown-submenu");
dropDownMenu2.add(new AnchorListItem("Item 1"));
HTML child = new HTML();
child.addStyleName("caret");
anchorButton2.add(child);
anchorButton2.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
anchorButton2.removeStyleName("dropdown-toggle");
listDropDown.addStyleName("open");
if(!listDropDown2.getStyleName().contains("open")){
listDropDown2.addStyleName("open");
}else{
listDropDown2.removeStyleName("open");
}
}
});
listDropDown2.add(anchorButton2);
anchorButton2.removeStyleName("dropdown-toggle");
listDropDown2.add(dropDownMenu2);
dropDownMenu.add(listDropDown2);
Bootstrap 3 does not support submenus. This is because Bootstrap 3 is a mobile first framework and submenus don't make sense on mobile.
If you still want to use submenus, you can easily add them yourself. You'll have to add the CSS referenced there somewhere in your app where it will be included and create a DropDownSubmenu
widget, very similar to DropDownMenu
, but using the style dropdown-submenu
, instead of dropdown-menu
.