Creating the left-hand sidebar

In this recipe, we are going to create a sidebar to be placed on the left-hand side of the homepage. This sidebar will be used for navigation.

How to do it...

  1. Define the method getLeftSidebar:
    public ContentPanel getLeftSideBar()
    {
    ContentPanel leftSidebarPanel = new ContentPanel();
    leftSidebarPanel.setHeading("Left Sidebar");
    return leftSidebarPanel;
    }
    
  2. Call the add method of class ContentPanel in the constructor to add the sidebar in the content panel:
    add(getLeftSideBar(), leftSidebarLayoutData);
    

How it works...

The method getLeftSideBar creates a content panel instance and sets a heading Left Sidebar. This heading will be modified later.

The left-hand sidebar created by this method is added in the west region of the main content panel by invoking add(getLeftSideBar(), leftSidebarLayoutData) in the constructor.

See also

  • The Creating the home page layout class recipe
  • The Adding the banner recipe
  • The Adding menus recipe
  • The Creating the right-hand sidebar recipe
  • The Creating the main content panel recipe
  • The Creating the footer recipe
  • The Using the HomePage instance in EntryPoint recipe