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

public class Modal<T> extends GenericPanel<T>
The Modal dialog is a simple component with header, footer and body.
Author:
miha
See Also:
  • Field Details

  • Constructor Details

    • Modal

      public Modal(String markupId)
      Constructor.
      Parameters:
      markupId - The non-null id of this component
    • Modal

      public Modal(String id, IModel<T> model)
      Constructor.
      Parameters:
      id - The non-null id of this component
      model - The component's body model
  • Method Details

    • onInitialize

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

      protected Component createHeaderCloseButton(String id)
      Factory method for the Modal's header 'closebutton' By default it generates the markup for original Bootstrap Modal closebutton
      Parameters:
      id - The component id
      Returns:
      the close button
    • createHeaderLabel

      protected Component createHeaderLabel(String id, String label)
      Factory method for the Modal's header label
      Parameters:
      id - The component id
      Returns:
      The header label
    • createHeader

      protected MarkupContainer createHeader(String id)
      Factory method for the Modal's header
      Parameters:
      id - The component id
      Returns:
      The header container
    • createFooter

      protected MarkupContainer createFooter(String id)
      Factory method for the Modal's footer
      Parameters:
      id - The component id
      Returns:
      The footer container
    • createDialog

      protected WebMarkupContainer createDialog(String id)
      Creates a container for the 'modal-dialog' div. It is used to set the size of the modal.
      Parameters:
      id - The component id
      Returns:
      The dialog container
    • size

      public Modal<T> size(Modal.Size size)
      Sets the size of the modal.
      Parameters:
      size - The size of the modal dialog.
      Returns:
      this, for method chaining
    • fullscreen

      public Modal<T> fullscreen(Modal.Fullscreen fullscreen)
      Sets fullscreen modal.
      Parameters:
      fullscreen - Fullscreen mode of the modal dialog.
      Returns:
      this, for method chaining
    • onComponentTag

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

      protected void onClose(IPartialPageRequestHandler target)
      hook to react on modal close event.
      Parameters:
      target - The current IPartialPageRequestHandler
    • header

      public Modal<T> header(IModel<String> label)
      Sets the header label text.
      Parameters:
      label - The header label
      Returns:
      This
    • header

      public Modal<T> header(IModel<String> label, boolean escapeMarkup)
      Sets the header label text and whether model strings should be escaped.
      Parameters:
      label - The header label
      escapeMarkup - True is model strings should be escaped
      Returns:
      This
    • setFooterVisible

      public Modal<T> setFooterVisible(boolean visible)
      Sets whether the footer and any children are visible.
      Parameters:
      visible - True if footer and any children should be visible
      Returns:
      This
    • setHeaderVisible

      public Modal<T> setHeaderVisible(boolean visible)
      Sets whether the header and any children are visible.
      Parameters:
      visible - True if header and any children should be visible
      Returns:
      This
    • setUseCloseHandler

      public final Modal<T> setUseCloseHandler(boolean useCloseHandler)
      Sets whether the close handler is used or not. Default is false.
      Parameters:
      useCloseHandler - True if close handler should be used
      Returns:
      This
    • show

      public Modal<T> show(boolean show)
      Sets the initial visibility of the modal dialog.
      Parameters:
      show - Whether to show the dialog or not
      Returns:
      This
    • setCloseOnEscapeKey

      public Modal<T> setCloseOnEscapeKey(boolean close)
      Sets a flag that decides whether using the ESC keyboard key will close this modal
      Parameters:
      close - The flag that is used to decide whether to close on ESC or not
      Returns:
      This
    • setBackdrop

      public Modal<T> setBackdrop(Modal.Backdrop backdrop)
      Sets a flag that decides whether using the ESC keyboard key will close this modal
      Parameters:
      backdrop - Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn't close the modal on click.
      Returns:
      This
    • appendCloseDialogJavaScript

      public Modal<T> appendCloseDialogJavaScript(IPartialPageRequestHandler target)
      Append dialog close/hide JavaScript to current AJAX request target.
      Parameters:
      target - The Ajax request handler
      Returns:
      This instance, for chaining
    • close

      public Modal<T> close(IPartialPageRequestHandler target)
      Parameters:
      target - The Ajax request handler
      Returns:
      This instance, for chaining
    • appendShowDialogJavaScript

      public Modal<T> appendShowDialogJavaScript(IPartialPageRequestHandler target)
      Append dialog show JavaScript to current request AJAX target.
      Parameters:
      target - current ajax request target
      Returns:
      this instance for chaining
    • show

      public Modal<T> show(IPartialPageRequestHandler target)
      Parameters:
      target - The Ajax request handler
      Returns:
      This instance, for chaining
    • createActionScript

      protected String createActionScript(String markupId, String action)
      creates an action script to open/close the dialog on client side.
      Parameters:
      markupId - The component's markup id
      action - Possible values: show/hide
      Returns:
      new script.
    • addOpenerAttributesTo

      public Modal<T> addOpenerAttributesTo(Component component)
    • addCloseButton

      public Modal<T> addCloseButton(IModel<String> label)
      adds a close button with specific label
      Parameters:
      label - The label of close button
      Returns:
      this instance
    • addCloseButton

      public Modal<T> addCloseButton()
      adds a close button with default label ("Close")
      Returns:
      this instance
    • addButton

      public Modal<T> addButton(Component button)
      adds a button to footer section.
      Parameters:
      button - Button to add to footer
      Returns:
      this instance.
    • onConfigure

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

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

      protected String createBasicInitializerScript(String markupId)
      creates the basic initialization script of the modal dialog. Override this to pass in your custom initialization, add event handlers, etc.
      Parameters:
      markupId - markup id
      Returns:
      initializer script
    • useFadein

      protected final boolean useFadein()
      Returns:
      true, if fade in animation is activated
    • useKeyboard

      protected final boolean useKeyboard()
      Returns:
      true, if keyboard usage is activated
    • showImmediately

      protected final boolean showImmediately()
      Returns:
      true, if modal dialog should be shown after initialization
    • setFadeIn

      public final Modal<T> setFadeIn(boolean fadein)
      Whether to fadein/fadeout the modal dialog or not
      Parameters:
      fadein - true, if dialog should be animated
      Returns:
      This
    • setUseKeyboard

      public final Modal<T> setUseKeyboard(boolean keyboard)
      Whether to enable keyboard interaction like ESC to close the dialog.
      Parameters:
      keyboard - true, if keyboard interaction is enabled
      Returns:
      This
    • setDisableEnforceFocus

      public final Modal<T> setDisableEnforceFocus(boolean disable)
      Whether the modal should not enforce the focus.
      Parameters:
      disable - true, if the modal should not enforce the focus
      Returns:
      This instance, for chaining