Class NavBar

All Implemented Interfaces:
Animatable<NavBar>

public class NavBar extends Component<NavBar> implements Animatable<NavBar>
  • Constructor Details

    • NavBar

      public NavBar()
      Creates a navbar component.
    • NavBar

      public NavBar(NavBarTheme theme)
      Creates a navbar component based on the specified theme.
      Parameters:
      theme - Navbar display theme If not specified or null is set, the navbar component is displayed using the default theme. Available themes are listed in the enum NavBarTheme.
    • NavBar

      public NavBar(String language)
      Creates a navbar component using the specified language.
      Parameters:
      language - Language code for the component If not specified or null is set, the application’s default language is used. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
    • NavBar

      public NavBar(String id, String language)
      Creates a navbar component using the specified unique ID and language code.
      Parameters:
      id - Unique component ID
      language - Language code for the component If not specified or null is set, the component is created using the application’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
    • NavBar

      public NavBar(String id, String language, NavBarTheme theme)
      Creates a navbar component using the specified unique ID, language code and theme.
      Parameters:
      id - Unique component ID
      language - Language code for the component If not specified or null is set, the component is created using the application’s default language. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      theme - Navbar display theme If not specified or null is set, the navbar component is created using the specified theme. Available themes are listed in the enum NavBarTheme.
  • Method Details

    • setTheme

      public NavBar setTheme(NavBarTheme theme)
      Sets the display theme for the navbar.
      Parameters:
      theme - Component theme If not specified or null is set, the application’s default theme is used to display the component. Available themes are listed in the enum NavBarTheme.
      Returns:
      Navbar component
    • getTheme

      public NavBarTheme getTheme()
      Gets the navbar’s theme.
      Returns:
      Navbar theme
    • setBorderRadius

      public NavBar setBorderRadius(boolean radiusOn)
      Sets the border radius for navbar component elements. If the border radius is enabled, icons, the user’s avatar, the search field and corners of images in popup windows will be rounded. If disabled, all the above elements will be displayed as having square corners. By default, component border radius is disabled.
      Parameters:
      radiusOn - If true is set, the border radius functionality is enabled for the component, otherwise it is disabled.
      Returns:
      Navbar component
    • isBorderRadius

      public boolean isBorderRadius()
      Checks if the border radius functionality is enabled for the navbar component.
      Returns:
      If true is set, the navbar’s border radius is enabled, otherwise it is disabled.
    • setAutoPin

      public NavBar setAutoPin(boolean autoPin)
      Sets whether the navbar component should be automatically minimized. If the user opens the application on a device with a small screen (e.g. a cell phone) or reduces the application windows size, the navbar component should be automatically minimized. If this happens, only icons are displayed instead of whole menu items. By default, this functionality is disabled.
      Parameters:
      autoPin - If true is specified, the navbar component is minimized for a smaller screen size, otherwise the component is not resized
      Returns:
      Navbar component
    • isAutoPin

      public boolean isAutoPin()
      Checks whether automatic component resizing is enabled.
      Returns:
      If true is specified, the functionality is enabled, otherwise it is disabled.
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<NavBar>
      Returns:
      If the componentwas drawn, true, otherwise false
    • setBrand

      public NavBar setBrand(String brand)
      Sets the text on the top of the navbar component.
      Parameters:
      brand - Text on the top of the navbar component If null is set, no text is displayed on the top of the navbar component.
      Returns:
      Navbar component
    • setBrand

      public NavBar setBrand(Icon icon, String brand)
      Sets the text on the top of the navbar component.
      Parameters:
      icon - The icon appearing before the text on the top of the navbar If null is specified, no navbar text icon is displayed. Available icons are listed in the enum Icon.
      brand - Text on the top of the navbar component If null is set, no text is displayed on the top of the navbar component.
      Returns:
      Navbar component
    • setBrand

      public NavBar setBrand(String brand, ClickEventHandler clickHandler)
      Sets the text on the top of the navbar component.
      Parameters:
      brand - Text on the top of the navbar component If null is set, no text is displayed on the top of the navbar component.
      clickHandler - Text click event handler implementation If not specified or null is set, the click event for the navbar top text is not handled.
      Returns:
      Navbar component
    • setBrand

      public NavBar setBrand(Icon icon, String brand, ClickEventHandler clickHandler)
      Sets the text on the top of the navbar component.
      Parameters:
      icon - The icon appearing before the text on the top of the navbar If null is set, no icon is displayed before the navbar component text. Available icons are listed in the enum Icon.
      brand - Text on the top of the navbar component If null is set, no text is displayed on the top of the navbar component.
      clickHandler - Text click event handler implementation If not specified or null is set, the click event for the navbar top text is not handled.
      Returns:
      Navbar component
    • getBrand

      public String getBrand()
      Gets the text on the top of the navbar component.
      Returns:
      The text on the top of the navbar or null if no text is displayed on the top of the navbar
    • getIcon

      public Icon getIcon()
      Gets the icon before the text on the top of the navbar.
      Returns:
      Navbar icon or null if no icon is displayed before the text on the top of the navbar
    • setUserPicture

      public NavBar setUserPicture(String pictureUrl)
      Sets the avatar image displayed in the navbar header.
      Parameters:
      pictureUrl - Relative URL for navbar header image The URL specified here must be relative to the application URL.
      Returns:
      Navbar component
    • getUserPicture

      public String getUserPicture()
      Gets the user’s avatar image.
      Returns:
      Relative URL of the user’s avatar image or null if there is no avatar set
    • setUsername

      public NavBar setUsername(String username)
      Sets the username on the navbar.
      Parameters:
      username - Username If null is set, no username is displayed on the component.
      Returns:
      Navbar component
    • getUsername

      public String getUsername()
      Gets the username displayed on the navbar.
      Returns:
      Username displayed in the navbar or null if no username is displayed in the navbar
    • setRole

      public NavBar setRole(String role)
      Sets the role for navbar component elements.
      Parameters:
      role - User role If null is set, no user role is set in the navbar.
      Returns:
      Navbar component
    • getRole

      public String getRole()
      Gets the user role assigned to the navbar.
      Returns:
      The user role or null if no user role is present in the navbar
    • setStatus

      public NavBar setStatus(String status)
      Sets the navbar component’s displayed user status.
      Parameters:
      status - Text status If null is set, no user status text is displayed in the navbar component.
      Returns:
      Navbar component
    • getStatus

      public String getStatus()
      Gets the user status text in the navbar.
      Returns:
      User status text or null if no user status text is displayed
    • addSearch

      public NavBar addSearch(NavBarSeachHandler searchHandler)
      Adds a generic search component to the navbar. If you add a search component to the navbar, an input field will appear below the header and above the menu items. Users can specify a search term here. The search must be performed by the NavBarSeachHandler implementation passed to the method.
      The placeholder text that appears on the search component ("Search ...." by default) can be modified or localized using MessageSourceAPI by entering the navBar.searchItemPlaceholder key.
      Parameters:
      searchHandler - Search implementation
      Returns:
      Navbar component
    • setBackgroundImageUrl

      public NavBar setBackgroundImageUrl(String imageUrl)
      Sets the background image for the navbar component. If you specify a background image for the component, the theme’s default background becomes transparent and it shows the specified image.
      Parameters:
      imageUrl - URL of the background image The specified URL must be different from the application’s default URL. If null is specified, no background image is set for the component and the default background color will not be transparent.
      Returns:
      Navbar component
    • getBackgroundImageUrl

      public String getBackgroundImageUrl()
      Gets the relative URL of the navbar’s background image.
      Returns:
      Relative URL of the navbar’s background image or null if no background image is set
    • removeSearch

      public NavBar removeSearch()
      Removes the search component from the navbar.
      Returns:
      Navbar component
    • isSearchVisible

      public boolean isSearchVisible()
      Checks if a search component is placed on the navbar.
      Returns:
      If true is returned, there is a search component placed on the navbar, otherwise not.
    • toggle

      public NavBar toggle()
      Hides or makes the navbar component visible. If the navbar component is visible, the method hides it. If it is hidden, it will be made visible.
      Returns:
      Navbar component
    • isToggled

      public boolean isToggled()
      Checks if the navbar component is visible.
      Returns:
      If true is set, the navbar component is visible. If false is set, it is hidden.
    • pin

      public NavBar pin()
      Sets the navbar component’s size. If the navbar component is full-size, the method minimizes it. In this case you will see only icons instead of menu items. If the user moves the mouse over the component, it will return to full-size. If the user moves the mouse pointer elsewhere, the component will be minimized again. If the component is already minimized, the method will restore its original size.
      Returns:
      Navbar component
    • isPinned

      public boolean isPinned()
      Checks if the component is displayed in full size.
      Returns:
      If true is returned, the component is displayed minimized. If false is set, it is displayed in full size.
    • createHeaderItem

      public NavBar createHeaderItem(String headerText)
      Adds a header type menu item to the component. Such menu items cannot be clicked, they are only for grouping other menu items.
      Parameters:
      headerText - The header text to be displayed. If null is set, an empty header is displayed in the menu.
      Returns:
      Navbar component
    • createItem

      public NavBarItem createItem(String name, Icon icon, String title)
      Adds a new main menu item to the component.
      Parameters:
      name - Menu item name (mandatory)
      icon - Menu item icon If null is specified, no icon is displayed on the menu item. Available icons are listed in the enum Icon.
      title - Menu item text If null is specified, no text will appear on the menu item.
      Returns:
      The created menu item component
    • findByName

      public NavBarItem findByName(String name)
      Looks up a menu item in the navbar based on its name. The method checks not also main menu items, but also returns sub menu items. If names in the navbar are not unique and there are more menu items by the specified name, the method returns the first menu item match.
      Parameters:
      name - The menu item name searched for
      Returns:
      The first menu item match or null if there is no menu item by that name
    • removeItem

      public NavBar removeItem(String name)
      Removes a menu item from the navbar component by its name.
      Parameters:
      name - The name of the menu item to be removed
      Returns:
      Navbar component
    • onOpenPage

      protected void onOpenPage(String pageId)
      Parameters:
      pageId - The page id
    • addMenu

      public NavBar addMenu(String menuName, String title, CurrentUser user)
      Adds an entire menu to the navbar with the specified header text. Use this method to add a menu created in the Startup class to the component by specifying its name. In this case all menu items are placed on the component and previous settings also take effect, such as navigation or click event handlers.
      Parameters:
      menuName - Menu name to be added to the component If null is set or a non-existing (undefined) name is specified, the method does not work.
      title - Header text above the menu If null is specified, no text will appear above the menu.
      user - Logged in user If null is specified, only public menu items are displayed. If you specify a user, all menu items in the menu are displayed to which the user has access.
      Returns:
      Navbar component
    • addFooterButton

      public NavBar addFooterButton(NavBarFooterButton button)
      Adds a footer button to the navbar component.
      Parameters:
      button - An instance of NavBarFooterButton
      Returns:
      Navbar component
      See Also:
    • addFooterButtons

      public NavBar addFooterButtons(NavBarFooterButton... buttons)
      Adds multiple footer buttons to the component.
      Parameters:
      buttons - An enumeration of NavBarFooterButton component instances to be added to the component
      Returns:
      Navbar component
    • removeFooterButton

      public NavBar removeFooterButton(NavBarFooterButton button)
      Removes a footer button from the navbar.
      Parameters:
      button - The NavBarFooterButton instance to be removed
      Returns:
      Navbar component
    • addComponent

      public NavBar addComponent(Component<?> component)
      Description copied from class: Component
      Adds the specified component as a subcomponent, and redraws the component immediately
      Overrides:
      addComponent in class Component<NavBar>
      Parameters:
      component - The component to be added
      Returns:
      The component