Options
All
  • Public
  • Public/Protected
  • All
Menu

PrimeFaces ConfirmDialog Widget

ConfirmDialog is a replacement to the legacy JavaScript confirmation box. Skinning, customization and avoiding popup blockers are notable advantages over the classic JavaScript confirmation box.

Type Parameters

Hierarchy

Index

Constructors

  • Creates a new instance of this widget. Please note that you should NOT override this constructor. Instead, override the init method, which is called at the end of the constructor once the instance is created.

    Type Parameters

    Parameters

    • cfg: PartialWidgetCfg<TCfg>

      The widget configuration to be used for this widget instance. This widget configuration is usually created on the server by the javax.faces.render.Renderer for this component.

    Returns ConfirmDialog<TCfg>

Properties

appendTo: null | string

The search expression for the element to which the overlay panel should be appended.

cfg: PartialWidgetCfg<TCfg>

The configuration of this widget instance. Please note that no property is guaranteed to be present, you should always check for undefined before accessing a property. This is partly because the value of a property is not transmitted from the server to the client when it equals the default.

closeIcon: JQuery<HTMLElement>

DOM element of the icon for closing this dialog, when this dialog is closable (an x by default).

content: JQuery<HTMLElement>

DOM element of the container for the content of this dialog.

Array of registered listeners invoked when this widget is destroyed. You should normally not use modify this directly, use addDestroyListener instead.

focusedElementBeforeDialogOpened: HTMLElement

Element that was focused before the dialog was opened.

footer: JQuery<HTMLElement>

DOM element of the container with the footer of this dialog.

icon: JQuery<HTMLElement>

DOM element of the icon displayed next to the confirmation message.

icons: JQuery<HTMLElement>

DOM elements of the title bar icons of this dialog.

id: string | string[]

The client-side ID of this widget, with all parent naming containers, such as myForm:myWidget. This is also the ID of the container HTML element for this widget. In case the widget needs multiple container elements (such as Paginator), this may also be an array if IDs.

iframeFix?: JQuery<HTMLElement>

The DOM element of the overlay that is put over iframes during a resize.

jq: JQuery<HTMLElement>

The jQuery instance of the container element of this widget. In case id is an array, it will contain multiple elements. Please note that some widgets have got not DOM elements at all, in this case this will be an empty jQuery instance.

jqEl: HTMLElement

The native DOM element instance of the container element of this widget (same element as the jq property).

jqId: string

A CSS selector for the container element (or elements, in case id is an array) of this widget, This is usually an ID selector (that is properly escaped). You can select the container element or elements like this: $(widget.jqId).

lastScrollTop?: number

The last known vertical scrolling position.

loaded?: boolean

Whether the dialog content was already loaded (when dynamic loading via AJAX is enabled.)

maximizeIcon: JQuery<HTMLElement>

DOM element of the icon for maximizing this dialog, when this dialog can be maximized.

maximized?: boolean

Whether the dialog is currently maximized.

message: JQuery<HTMLElement>

DOM element of the confirmation message displayed in this confirm dialog.

minimizeClone: JQuery<HTMLElement>

DOM element clone of the JQ to be used for minimizing.

minimizeIcon: JQuery<HTMLElement>

DOM element of the icon for minimizing this dialog, when this dialog can be minimized.

minimized?: boolean

Whether the dialog is currently minimized.

modalOverlay: JQuery<HTMLElement>

The DOM element that is displayed as an overlay with the appropriate z-index and position. It is usually a child of the body element.

parent: JQuery<HTMLElement>

The DOM element of the parent that contains this dialog, i.e the element to which the dialog was appended.

positionInitialized: boolean

Whether the position of the dialog was already set. If not, it must be set the next time the dialog is shown.

Array of registered listeners invoked when this widget is refreshed. You should normally not use modify this directly, use addRefreshListener instead.

resizers?: JQuery<HTMLElement>

The DOM element of the resize icons for resizing the dialog, if resizing is enabled.

state?: ClientState

The client-side state of the dialog such as its width and height. The client-side state can be preserved during AJAX updates by sending it to the server.

title: JQuery<HTMLElement>

DOM element of the title bar text.

titlebar: JQuery<HTMLElement>

DOM element of the title bar container of this dialog.

widgetVar: string

The name of the widget variables of this widget. The widget variable can be used to access a widget instance by calling PF('myWidgetVar').

Methods

  • _show(duration?: string | number): void
  • Performs the client-side actions needed to actually show this dialog. Compare to show, which loads the dialog content from the server if required, then call this method.

    Parameters

    • Optional duration: string | number

      Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings fast and slow can be supplied to indicate durations of 200 and 600 milliseconds, respectively.

    Returns void

  • Lets you register a listener that is called before the component is destroyed.

    When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. When the element is removed from the DOM by the update, the DOM element is detached from the DOM and all destroy listeners are called. This makes it possible to add listeners from outside the widget code.

    If you call this method twice with the same listener, it will be registered twice and later also called twice.

    Note that for this to work, you must not override the destroy method; or if you do, call super.

    Also, after this widget was detached is done, all destroy listeners will be unregistered.

    since

    7.0

    Parameters

    Returns void

  • When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. However, no new instance of the widget is created. Instead, after the DOM element was replaced, all refresh listeners are called. This makes it possible to add listeners from outside the widget code.

    If you call this method twice with the same listener, it will be registered twice and later also called twice.

    Note that for this to work, you must not override the refresh method; or if you do, call super.

    Also, after the refresh is done, all refresh listeners will be deregistered. If you added the listeners from within this widget, consider adding the refresh listeners not only in the init method, but also again in the refresh method after calling super.

    since

    7.0.0

    Parameters

    Returns void

  • applyARIA(): void
  • Applies all ARIA attributes to the contents of this dialog.

    Returns void

  • applyFocus(): void
  • Puts focus on the first element that can be focused.

    override

    Returns void

  • bindEvents(): void
  • Sets up all event listeners required by this widget.

    Returns void

  • bindResizeListener(): void
  • Each widget may have one or several behaviors attached to it. This method calls all attached behaviors for the given event name. In case no such behavior exists, this method does nothing and returns immediately.

    A behavior is a way for associating client-side scripts with UI components that opens all sorts of possibilities, including client-side validation, DOM and style manipulation, keyboard handling, and more. When the behavior is triggered, the configured JavaScript gets executed.

    Behaviors are often, but not necessarily, AJAX behavior. When triggered, it initiates a request the server and processes the response once it is received. This enables several features such as updating or replacing elements dynamically. You can add an AJAX behavior via <p:ajax event="name" actionListener="#{...}" onstart="..." />.

    since

    7.0

    Parameters

    • event: string

      The name of an event to call.

    • Optional ext: Partial<ConfigurationExtender>

      Additional configuration that is passed to the AJAX request for the server-side callback.

    Returns void

  • destroy(): void
  • Will be called after an AJAX request if the widget container will be detached.

    When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. When the element is removed from the DOM by the update, the DOM element is detached from the DOM and this method gets called.

    Please note that instead of overriding this method, you should consider adding a destroy listener instead via addDestroyListener. This has the advantage of letting you add multiple listeners, and makes it possible to add additional listeners from code outside this widget.

    By default, this method just calls all destroy listeners.

    override

    Returns void

  • disableModality(overlay?: null | JQuery<HTMLElement>): void
  • Disabled modality for this widget and removes the modal overlay element, but does not change whether the overlay is currently displayed.

    Parameters

    • Optional overlay: null | JQuery<HTMLElement>

      The target overlay, if not given default to this.jq.

    Returns void

  • dock(zone: JQuery<HTMLElement>): void
  • Docks this dialog to the given docking zone. The docking zone is usually at the bottom of the screen and displays a list of minimized dialogs.

    Parameters

    • zone: JQuery<HTMLElement>

      Zone to dock to.

    Returns void

  • enableModality(overlay?: null | JQuery<HTMLElement>): void
  • Enables modality for this widget and creates the modal overlay element, but does not change whether the overlay is currently displayed.

    Parameters

    • Optional overlay: null | JQuery<HTMLElement>

      The target overlay, if not given default to this.jq.

    Returns void

  • fitViewport(): void
  • Makes this dialog fit the current browser window, if the fitViewport option is enabled.

    Returns void

  • getBehavior(name: string): null | Behavior
  • Each widget may have one or several behaviors attached to it. This method returns the callback function for the given event.

    Note: Do not call the method directly, the recommended way to invoke a behavior is via callBehavior.

    A behavior is a way for associating client-side scripts with UI components that opens all sorts of possibilities, including client-side validation, DOM and style manipulation, keyboard handling, and more. When the behavior is triggered, the configured JavaScript gets executed.

    Behaviors are often, but not necessarily, AJAX behavior. When triggered, it initiates a request the server and processes the response once it is received. This enables several features such as updating or replacing elements dynamically. You can add an AJAX behavior via <p:ajax event="name" actionListener="#{...}" onstart="..." />.

    Parameters

    • name: string

      The name of an event for which to retrieve the behavior.

    Returns null | Behavior

    The behavior with the given name, or null if no such behavior exists.

  • Each widget has got a container element, this method returns that container. This container element is usually also the element whose ID is the client-side ID of the JSF component.

    Returns JQuery<HTMLElement>

    The jQuery instance representing the main HTML container element of this widget.

  • getModalTabbables(): JQuery<HTMLElement>
  • This class makes sure a user cannot tab out of the modal and it stops events from targets outside of the overlay element. This requires that we switch back to the modal in case a user tabs out of it. What must be returned by this method are the elements to which the user may switch via tabbing.

    override

    Returns JQuery<HTMLElement>

    The DOM elements which are allowed to be focused via tabbing.

    (from super type DynamicOverlayWidget) The DOM elements which are allowed to be focused via tabbing. May be an empty jQuery instance when the modal contains no tabbable elements, but must not be undefined.

  • getParentForm(): JQuery<HTMLElement>
  • Gets the closest parent form for this widget.

    since

    10.0.0

    Returns JQuery<HTMLElement>

    A JQuery instance that either contains the form when found, or an empty JQuery instance when the form could not be found.

  • getParentFormId(): undefined | string
  • Gets the closest parent form ID for this widget lazily so it can be used in AJAX requests.

    since

    10.0.0

    Returns undefined | string

    Either the form ID or undefined if no form can be found.

  • hasBehavior(event: string): boolean
  • Each widget may have one or several behaviors attached to it. This method checks whether this widget has got at least one behavior associated with given event name.

    A behavior is a way for associating client-side scripts with UI components that opens all sorts of possibilities, including client-side validation, DOM and style manipulation, keyboard handling, and more. When the behavior is triggered, the configured JavaScript gets executed.

    Behaviors are often, but not necessarily, AJAX behavior. When triggered, it initiates a request the server and processes the response once it is received. This enables several features such as updating or replacing elements dynamically. You can add an AJAX behavior via <p:ajax event="name" actionListener="#{...}" onstart="..." />.

    Parameters

    • event: string

      The name of an event to check.

    Returns boolean

    true if this widget has the given behavior, false otherwise.

  • hide(duration?: string | number): void
  • Hide the dialog with an optional animation lasting for the given duration.

    Parameters

    • Optional duration: string | number

      Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings fast and slow can be supplied to indicate durations of 200 and 600 milliseconds, respectively.

    Returns void

  • A widget class should not declare an explicit constructor, the default constructor provided by this base widget should be used. Instead, override this initialize method which is called after the widget instance was constructed. You can use this method to perform any initialization that is required. For widgets that need to create custom HTML on the client-side this is also the place where you should call your render method.

    Please make sure to call the super method first before adding your own custom logic to the init method:

    PrimeFaces.widget.MyWidget = PrimeFaces.widget.BaseWidget.extend({
    init: function(cfg) {
    this._super(cfg);
    // custom initialization
    }
    });
    override

    Parameters

    • cfg: PartialWidgetCfg<TCfg>

      the widget configuraton

      (from super type BaseWidget) The widget configuration to be used for this widget instance. This widget configuration is usually created on the server by the javax.faces.render.Renderer for this component.

    Returns void

  • initPosition(): void
  • Positions this dialog on the screen as specified by the widget configuration.

    Returns void

  • initSize(): void
  • Computes and applies the correct size for this dialog, according to the current configuration.

    Returns void

  • isDetached(): boolean
  • Checks if this widget is detached, ie whether the HTML element of this widget is currently contained within the DOM (the HTML body element). A widget may become detached during an AJAX update, and it may remain detached in case the update removed this component from the component tree.

    Returns boolean

    true if this widget is currently detached, or false otherwise.

  • isVisible(): boolean
  • Checks whether this dialog is opened and visible. This method returns true irrespective of whether this dialog is minimized, maximized, or shown normally. Returns false only when this dialog is closed.

    Returns boolean

    true if this dialog is currently being shown, false otherwise.

  • loadContents(): void
  • Loads the content of the dialog via AJAx, if this dialog is dynamic and the the content has not yet been loaded.

    Returns void

  • moveToTop(): void
  • Moves this dialog to the top so that it is positioned above other elements and overlays.

    Returns void

  • onHide(event?: unknown, ui?: unknown): void
  • Called when this dialog was closed. Invokes the appropriate behaviors and event listeners.

    Parameters

    • Optional event: unknown

      Unused.

    • Optional ui: unknown

      Unused.

    Returns void

  • postShow(): void
  • Called after this dialog became visible. Triggers the behaviors and registered event listeners.

    Returns void

  • Used in ajax updates, reloads the widget configuration.

    When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. However, no new instance of the widget is created. Instead, after the DOM element was replaced, this method is called with the new widget configuration from the server. This makes it possible to persist client-side state during an update, such as the currently selected tab.

    Please note that instead of overriding this method, you should consider adding a refresh listener instead via addRefreshListener. This has the advantage of letting you add multiple listeners, and makes it possible to add additional listeners from code outside this widget.

    By default, this method calls all refresh listeners, then reinitializes the widget by calling the init method.

    override

    Parameters

    Returns void

    The value as returned by the init method, which is often undefined.

  • removeMinimize(): void
  • Called when this dialog is minimized. Restores the original position of this dialog.

    Returns void

  • removeScriptElement(clientId: string | string[]): void
  • Removes the widget's script block from the DOM. Currently, the ID of this script block consists of the client-side ID of this widget with the prefix _s, but this is subject to change.

    Parameters

    • clientId: string | string[]

      The client-side ID of the widget.

    Returns void

  • resetPosition(): void
  • Resets the dialog position as specified by the position property of this widget configuration.

    Returns void

  • restoreState(): void
  • Restores the state as saved by saveState, usually called after an AJAX update.

    Returns void

  • returnFocus(): void
  • Puts focus on the element that opened this dialog.

    Returns void

  • saveState(): void
  • Saves the current state of this dialog, such as its width and height. Used for example to preserve that state during AJAX updates.

    Returns void

  • setupDraggable(): void
  • Sets up all event listeners required to make this dialog draggable.

    Returns void

  • setupResizable(): void
  • Sets up all event listeners required to make this dialog resizable.

    Returns void

  • show(duration?: string | number): void
  • Displays this dialog. In case the dynamic option is enabled and the content was not yet loaded, this may result in an AJAX request to the sever to retrieve the content. Also triggers the show behaviors registered for this dialog.

    Parameters

    • Optional duration: string | number

      Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings fast and slow can be supplied to indicate durations of 200 and 600 milliseconds, respectively.

    Returns void

  • Shows the given message in this confirmation dialog.

    Parameters

    Returns void

  • toggleMaximize(): void
  • Toggle maxification, as if the user had clicked the maximize button. If this dialog is not yet maximized, maximizes it. If this dialog is already maximized, reverts it back to its orignal size.

    Returns void

  • toggleMinimize(): void
  • Toggles minification, as if the user had clicked the minimize button. If this dialog is not yet minimized, minimizes it. If this dialog is already minimized, restores its original position.

    Returns void

Generated using TypeDoc