All Implemented Interfaces:
Activatable, Serializable, Iterable<Component>, IEventSink, IEventSource, IFeedbackContributor, IConverterLocator, IMetadataContext<Serializable,Component>, IHeaderContributor, IRequestableComponent, IHierarchical<Component>, IClusterable
Direct Known Subclasses:
NavbarDropDownButton, SplitButton

public abstract class DropDownButton extends AbstractLink implements Activatable
Use any button to trigger a dropdown menu by placing it within a .btn-group and providing the proper menu markup.
Author:
miha
See Also:
  • Constructor Details

    • DropDownButton

      public DropDownButton(String id, IModel<String> model)
      Construct.
      Parameters:
      id - The markup id
      model - The label of the main button
    • DropDownButton

      public DropDownButton(String markupId, IModel<String> model, IModel<IconType> iconType)
      Construct.
      Parameters:
      markupId - The markup id
      model - The label of the main button
      iconType - The type of the icon
  • Method Details

    • onInitialize

      protected void onInitialize()
      Overrides:
      onInitialize in class MarkupContainer
    • getModel

      public IModel<String> getModel()
    • getIcon

      public Icon getIcon()
    • createCssClassName

      protected String createCssClassName()
      Returns:
      base css class name of button container element
    • addIconToBaseButton

      protected void addIconToBaseButton(Icon icon)
      adds an icon to the base button
      Parameters:
      icon - The icon to add
    • addToButton

      public final DropDownButton addToButton(Behavior behavior)
      adds a Behavior to the base button
      Parameters:
      behavior - to add
      Returns:
      this instance for chaining
    • newInitializerScript

      protected String newInitializerScript()
      Returns:
      new initializer script
    • appendToggleMenuScript

      public final void appendToggleMenuScript(IPartialPageRequestHandler target)
      appends a toggle menu script to a given IPartialPageRequestHandler.
      Parameters:
      target - the current target
    • setIconType

      public final DropDownButton setIconType(IconType iconType)
      sets the icon of the base button element
      Parameters:
      iconType - The IconType of the icon
      Returns:
      this element instance
    • newButton

      protected WebMarkupContainer newButton(String markupId, IModel<String> labelModel, IModel<IconType> iconTypeModel)
      creates a new button instance
      Parameters:
      markupId - The component's id
      labelModel - The label text as model
      iconTypeModel - The icon type as model
      Returns:
      a new button component
    • newButtonLabel

      protected Component newButtonLabel(String markupId, IModel<?> labelModel)
      creates a new icon component with given IconType.
      Parameters:
      markupId - The component' id
      labelModel - The label text as model
      Returns:
      new label component
    • newButtonIcon

      protected Icon newButtonIcon(String markupId, IModel<IconType> iconTypeModel)
      creates a new icon component with given IconType.
      Parameters:
      markupId - The component' id
      iconTypeModel - The icon type as model
      Returns:
      new icon component
    • renderHead

      public void renderHead(IHeaderResponse response)
      Specified by:
      renderHead in interface IHeaderContributor
      Overrides:
      renderHead in class Component
    • addButtonBehavior

      protected void addButtonBehavior(ButtonBehavior buttonBehavior)
      adds the button behavior to the base button of this dropdown component
      Parameters:
      buttonBehavior - - behavior to add
    • newSubMenuButtons

      protected abstract List<AbstractLink> newSubMenuButtons(String buttonMarkupId)
      creates a list of sub menu buttons which will be shown if sub menu will be opened.
      Parameters:
      buttonMarkupId - the markup id that all sub menu buttons must be use.
      Returns:
      list of sub menu buttons
    • newButtonList

      protected ButtonList newButtonList(String markupId)
      creates a new ButtonList that contains all buttons from newSubMenuButtons(String)
      Parameters:
      markupId - the markup id of ButtonList
      Returns:
      new ButtonList instance
    • setSize

      public DropDownButton setSize(Buttons.Size size)
      sets the size of the button
      Parameters:
      size - mandatory parameter
      Returns:
      this instance for chaining
    • setType

      public DropDownButton setType(Buttons.Type type)
      sets the type of the button
      Parameters:
      type - mandatory parameter
      Returns:
      this instance for chaining
    • setAlignment

      public DropDownButton setAlignment(DropDownAlignmentBehavior.Alignment... alignment)
      sets the dropdown menu alignment
      Parameters:
      alignment - The alignment of the button
      Returns:
      this instance for chaining
    • setVariation

      public DropDownButton setVariation(DropDownVariationBehavior.Variation variation)
      Sets the dropdown menu "drop" variation
      Parameters:
      variation - The "drop" variant of the button
      Returns:
      this instance for chaining
    • newMarkupSourcingStrategy

      protected final IMarkupSourcingStrategy newMarkupSourcingStrategy()
      Overrides:
      newMarkupSourcingStrategy in class Component
    • onComponentTag

      protected void onComponentTag(ComponentTag tag)
      Overrides:
      onComponentTag in class Component
    • isActive

      public boolean isActive(Component item)
      Description copied from interface: Activatable
      Decides whether the current instance (this) is the active item.
      Specified by:
      isActive in interface Activatable
      Parameters:
      item - the current instance as a Component
      Returns:
      true if the item is the current active one