All Implemented Interfaces:
Serializable, Iterable<Component>, IEventSink, IEventSource, IFeedbackContributor, IConverterLocator, IGenericComponent<String,GenericPanel<String>>, IMetadataContext<Serializable,Component>, IQueueRegion, IHeaderContributor, IRequestableComponent, IHierarchical<Component>, IClusterable
Direct Known Subclasses:
NotificationAlert

public class Alert extends GenericPanel<String>
A bootstrap styled panel for success, warning, and error messages usage:
     add(new Alert("id", Model.of("message text")));
 
Author:
miha
See Also:
  • Constructor Details

    • Alert

      public Alert(String id, IModel<String> message)
      Constructor.
      Parameters:
      id - the wicket component id.
      message - the alert message
    • Alert

      public Alert(String id, IModel<String> message, IModel<String> header)
      Constructor.
      Parameters:
      id - the wicket component id.
      message - the alert message
      header - the title of the alert message
  • Method Details

    • getMessage

      protected final Component getMessage()
    • onInitialize

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

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

      protected Component createMessage(String markupId, IModel<String> message)
      creates a new message component.
      Parameters:
      markupId - The component id
      message - The message as IModel
      Returns:
      new message component
    • setCloseButtonVisible

      public Alert setCloseButtonVisible(boolean visible)
      Sets whether the close button is visible.
      Parameters:
      visible - True if the close button is visible.
      Returns:
      This
    • renderHead

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

      public Alert withMessage(IModel<String> message)
      Sets the message.
      Parameters:
      message - The message.
      Returns:
      This instance for chaining.
    • withHeader

      public Alert withHeader(IModel<String> header)
      Sets the header message.
      Parameters:
      header - The header message.
      Returns:
      This instance for chaining.
    • type

      public Alert type(Alert.Type type)
      Sets the alert type.
      Parameters:
      type - to use.
      Returns:
      This.
    • hideAfter

      public Alert hideAfter(Duration duration)
      hides the alert box after given duration.
      Parameters:
      duration - the duration to use for closing the alert box
      Returns:
      this.
    • useInlineHeader

      public Alert useInlineHeader(boolean useInlineHeader)
      Whether to use an inline or block header.
      Parameters:
      useInlineHeader - true to use inline header
      Returns:
      This
    • onConfigure

      protected void onConfigure()
      Overrides:
      onConfigure in class Component
    • detachModel

      protected void detachModel()
      Overrides:
      detachModel in class Component