Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6367321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:32:00+00:00 2026-05-25T00:32:00+00:00

I have a vaadin application that redirect after login to a view with header

  • 0

I have a vaadin application that redirect after login to a view with header / left menu and a main panel.

how can I set the menu or any link to switch the main panel according to a specific contents

If I click contact It set ContactLayout in the main panel.

PS: I know how to set a menu like in vaadin documentation but I want to know what to set as command for the menu item.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:32:01+00:00Added an answer on May 25, 2026 at 12:32 am

    I suggest you to keep a Map<MenuItem,AbstractLayout> and when a MenuItem is clicked, remove all the components of your Panel, and add the layout get from the Map.

    Visually :

    public class TestApplication extends Application {
    
    private VerticalLayout contactLayout;
    
    private Panel mainPanel;
    
    Map<MenuItem, AbstractLayout> swapContentMap;
    
    @Override
    public void init() {
        Window mainWindow = new Window("Test Application");
    
    
        mainPanel = new Panel("Main Panel");
        mainWindow.addComponent(mainPanel);
    
        // Create all of your layout 
        // For now,  I just create a fake contact layout
        contactLayout = new VerticalLayout();
    
        // Here add your default layout to the right panel
        mainPanel.addComponent(contactLayout);
    
    
        Command myCommand = new MyCommand();
        MenuBar menuBar = new MenuBar();
        MenuItem menuItem = menuBar.addItem("Contact", myCommand);
        //add your other menu item
    
        swapContentMap = new HashMap<MenuBar.MenuItem, AbstractLayout>();
        swapContentMap.put(menuItem, contactLayout);
        //add your other menu item to the map.
    
    
        setMainWindow(mainWindow);
    }
    
    private class MyCommand implements Command
    {
    
        public void menuSelected(MenuItem selectedItem) 
        {
            TestApplication.this.mainPanel.removeAllComponents();
            TestApplication.this.mainPanel.addComponent(swapContentMap.get(selectedItem));
        }
    
    }
    

    }

    Hope it will work.

    Regards

    Éric

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple Vaadin application. I want to inject the main window
Have a n-tire web application and search often times out after 30 secs. How
I have developed a vaadin application for a friend of me. Now I want
I am building a web application that have several requirements for the client: 1.
This may be an incredibly stupid question, but I have a web application that
I have a Vaadin application and I am trying to display a PDF which
I have a download action implemented on my Vaadin application but for some reason
I have developed an application in Grails. It uses Vaadin framework for GUI. It
I have a vaadin application and I am trying to provide some REST Urls
I have a problem with compiling custom widgetsets for my vaadin application using Maven.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.