Menu options setting at user level

Gleb has shared a very useful sidemenu with some additional functionality i.e. sidemenu drawer. With is, we have a few different menu options for the users.

However, currently, it is hard-code and not user-selectable style. That is, the developer will decide what type of menu styling the application have which will be common across all user - SideMenu, SideMenu with the toggle or traditional menu bar on the top.

How about we give all such options to the end users to choose from? Based on the user’s choice or even some time to be practical - based on screen size the same user may choose the mobile menu while using in an iPad or 14" screen computer.

The solution for this could be adding options in Help >> Settings where the user can select something below as circled in red:


Trying something like this in ExtSettingsWindow screen but not sure where to save this setting data and how to retrieve and use it in ExtAppMainWindow screen.

public void init(Map<String, Object> params) {
    Map<String, Object> map = new LinkedHashMap<>();
    map.put("Side-Bar Menu", 1);
    map.put("Side-overflow Menu", 2);
    map.put("Top-down Menu", 3);

    String menuOption = userSettingService.loadSetting("menuType");
    if(menuOption !=null){
        if (menuOption.equals(1)) {
        }else if (menuOption.equals(2)) {
        } else {

public void onOkBtnClick() {

Would appreciate suggestions with a code snippet.

Moreover, I tried the following code to set the default sideMenu style in ExtAppMainWindow init method but it’s not working:

if (sideMenu.getSidePanel().getStyleName().contains("c-sidemenu-responsive")) {


In order to allow users selecting Main Window template you need to do the following:

  1. Create several main windows with different id. Pay attention that all of them must have route="main".
    In the sample app, in addition to the default main window, I added Main Window with SideMenu and registered it in web-screens.xml as follows:
<screen id="sideMenuMainWindow" template="com/company/demo/web/app/mainwindow/sidemenu/sidemenu-mainwindow.xml" route="main"/>
  1. Create an extended Settings Window.
    <groupBox id="groupBox">
        <grid id="grid">
                    <label id="mainScreenLabel" align="MIDDLE_LEFT" value="msg://mainWindow"/>
                    <lookupField id="mainWindowField"

You correctly used userSettingService for settings saving.

public class ExtSettingsWindow extends SettingsWindow {

    private LookupField<String> mainWindowField;

    protected void init(InitEvent initEvent) {

        // Values correspond to particular main screen ids
                "Tob Bar Menu", "mainWindow",
                "Side Menu", "sideMenuMainWindow"

        mainWindowField.addValueChangeListener(stringValueChangeEvent ->
                userSettingService.saveSetting(App.MAIN_WINDOW_SCREEN_ID, stringValueChangeEvent.getValue()));
  1. Create an extension of DefaultApp and register it in web-spring.xml:
    If a user logged in we can obtain main screen id and return it as a value of the root window.
public class App extends DefaultApp {
    public static final String MAIN_WINDOW_SCREEN_ID = "mainWindowScreenId";

    protected UserSettingService userSettingService;

    protected String routeTopLevelWindowId() {
        if (connection.isAuthenticated()) {
            String screenId = userSettingService.loadSetting("mainWindowScreenId");
            return Strings.isNullOrEmpty(screenId) ? "mainWindow" : screenId;
        } else {
            return "loginWindow";
<bean class=""
          scope="vaadin"/> (81.6 KB)


Thank you Gleb, this looks cool.
It seems that the same code works only for platform v7. I shall try it later in my project when I move it to this platform version.