Options
All
  • Public
  • Public/Protected
  • All
Menu

PrimeFaces SelectCheckboxMenu Widget

SelectCheckboxMenu is a multi select component that displays options in an overlay.

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 SelectCheckboxMenu<TCfg>

Properties

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.

checkboxes: JQuery<HTMLElement>

The DOM element for the checkboxes that can be selected.

closer?: JQuery<HTMLElement>

The DOM element for the button that closes the overlay panel with the select options (when the panel is shown).

defaultLabel: JQuery<HTMLElement>

The DOM element for the default label.

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

disabled: boolean

Whether this widget is currently disabled.

filterInput?: JQuery<HTMLElement>

DOM element of the input element used for entering a filter text, if filtering is enabled.

filterInputWrapper?: JQuery<HTMLElement>

DOM element of the wrapper that holds the input element used for entering a filter text, if filtering is enabled.

The filter that was selected and is currently used.

Map between the available filter types and the filter implementation.

groupHeaders: JQuery<HTMLElement>

The DOM elements for the headers of each option group.

header?: JQuery<HTMLElement>

DOM element of the header of the overlay panel with the available select items, when the overlay panel is shown.

hideOverlayHandler?: UnbindCallback

Unbind callback for the hide overlay handler.

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.

inputs: JQuery<HTMLElement>

The DOM elements for the hidden inputs for each checkbox option.

isDynamicLoaded: boolean

When loading the panel with the available options lazily: if they have been loaded already.

itemContainer: JQuery<HTMLElement>

The DOM element for the container with the available checkbox options.

itemContainerWrapper: JQuery<HTMLElement>

The DOM element for the wrapper with the container with the available checkbox options.

items: JQuery<HTMLElement>

The DOM elements for the the available checkbox options.

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.

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).

keyboardTarget: JQuery<HTMLElement>

The DOM element for the hidden input element that that can be selected via pressing tab.

label: JQuery<HTMLElement>

The DOM element for the label indicating the currently selected option.

labelContainer: JQuery<HTMLElement>

The DOM element for the container with the label indicating the currently selected option.

labelId: string

ID of the label element that indicates the currently selected option.

menuIcon: JQuery<HTMLElement>

The DOM element for the icon for bringing up the overlay panel.

multiItemContainer: JQuery<HTMLElement>

The DOM element for the container with the tags representing the selected options.

panel: JQuery<HTMLElement>

The DOM element for the overlay panel with the available checkbox options.

panelId: JQuery<HTMLElement>

ID of the DOM element for the overlay panel with the available checkbox options.

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

resizeHandler?: UnbindCallback

Unbind callback for the resize handler.

scrollHandler?: UnbindCallback

Unbind callback for the scroll handler.

tabindex: string

Tab index of this widget.

toggler?: JQuery<HTMLElement>

The wrapping DOM element of the toggler for selecting or unselecting all options in the overlay panel with all selected items (when the overlay panel is shown).

togglerBox?: JQuery<HTMLElement>

The DOM element with the toggler checkbox for selecting or unselecting all options in the overlay panel with all selected items (when the overlay panel is shown).

togglerCheckboxInput?: JQuery<HTMLElement>

The DOM element for the hidden input of the Select All checkbox.

transition?: null | CssTransitionHandler

Handler for CSS transitions used by this widget.

triggers: JQuery<HTMLElement>

The DOM elements for the buttons that can trigger (hide or show) the overlay panel with the available checkbox options.

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').

widthAligned: boolean

Whether the width of the overlay panel was aligned already.

Methods

  • _renderPanel(): void
  • Creates the overlay panel with the checkboxes for the selectable option, and also sets up the event listeners for the panel.

    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

  • alignPanel(): void
  • Align the overlay panel with the available checkbox options so that is is positioned next to the the button.

    Returns void

  • bindCheckboxHover(item: JQuery<HTMLElement>): void
  • Sets up the event listeners for hovering over the checkboxes. Adds the appropriate hover style classes.

    Parameters

    • item: JQuery<HTMLElement>

      A checkbox for which to add the event listeners.

    Returns void

  • bindCheckboxKeyEvents(items: JQuery<HTMLElement>): void
  • Sets up the keyboard event listeners for the given checkbox options.

    Parameters

    • items: JQuery<HTMLElement>

      Checkbo options for which to add the event listeners.

    Returns void

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

    Returns void

  • bindKeyEvents(): void
  • Sets up the event listeners for all keyboard related events other than the overlay panel, such as pressing space to bring up the overlay panel.

    Returns void

  • bindMultipleModeEvents(): void
  • When multi select mode is enabled: Sets up the event listeners for the overlay panel.

    Returns void

  • bindPanelContentEvents(): void
  • Sets up the event listeners for the overlay panel with the selectable checkbox options.

    Returns void

  • bindPanelEvents(): void
  • Sets up all panel event listeners

    Returns void

  • bindPanelKeyEvents(): void
  • Sets up the event listeners for all keyboard related events of the overlay panel, such as pressing space to toggle a checkbox.

    Returns 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

  • check(checkbox: JQuery<HTMLElement>, updateInput: boolean): void
  • Selects the given checkbox option.

    Parameters

    • checkbox: JQuery<HTMLElement>

      Checkbox option to select.

    • updateInput: boolean

      If true, update the hidden input field with the current value of this widget.

    Returns void

  • checkAll(silent?: boolean): void
  • Selects all available options.

    Parameters

    • Optional silent: boolean

      true to suppress triggering event listeners, or false otherwise.

    Returns void

  • configureSelectAllAria(): void
  • Configures the ARIA label for the select all checkbox.

    Returns void

  • containsFilter(value: string, filter: string): boolean
  • Implementation of a PrimeFaces.widget.SelectCheckboxMenu.FilterFunction that matches the given option when it contains the given search text.

    Parameters

    • value: string

      Text of an option.

    • filter: string

      Value of the filter.

    Returns boolean

    true when the text of the contains the filter value, or false otherwise.

  • createMultipleItem(item: JQuery<HTMLElement>): void
  • When multi mode is enabled: Creates a tag for the given item that was checked.

    Parameters

    • item: JQuery<HTMLElement>

      The checkbox item that was checked.

    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.

    Returns void

  • disable(): void
  • Disables this input so that the user cannot enter a value anymore.

    Returns void

  • enable(): void
  • Enables this input so that the user can enter a value.

    Returns void

  • endsWithFilter(value: string, filter: string): boolean
  • Implementation of a PrimeFaces.widget.SelectCheckboxMenu.FilterFunction that matches the given option when it ends with the given search text.

    Parameters

    • value: string

      Text of an option.

    • filter: string

      Value of the filter.

    Returns boolean

    true when the text of the options ends with the filter value, or false otherwise.

  • filter(value: string): void
  • Filters the available options in the overlay panel by the given search value. Note that this does not bring up the overlay panel, use show for that.

    Parameters

    • value: string

      A value against which the available options are matched.

    Returns void

  • fireToggleSelectEvent(checked: boolean): void
  • Triggers the select behavior, if any, when a checkbox option was selected or unselected.

    Parameters

    • checked: boolean

      Whether the checkbox option is now checked.

    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.

  • 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.

  • handleViewportChange(): void
  • Fired when the browser viewport is resized or scrolled. In Mobile environment we don't want to hider the overlay we want to re-align it. This is because on some mobile browser the popup may force the browser to trigger a resize immediately and close the overlay. See GitHub #7075.

    Returns void

  • 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(): void
  • Hides the overlay panel with the available checkbox options.

    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 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

  • 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.

  • isLoaded(): boolean
  • Has the panel been loaded with checkbox data yet?

    Returns boolean

    true when the panel has been loaded with checkbox items

  • postHide(): void
  • Callback that is invoked after the overlay panel with the checkbox options was hidden.

    Returns void

  • postShow(): void
  • Callback that is invoked after the overlay panel with the checkbox options was made visible.

    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.

  • registerTrigger(): void
  • Mark trigger and descandants of trigger as a trigger for a primefaces overlay.

    Returns void

  • removeMultipleItem(item: JQuery<HTMLElement>): void
  • When multi mode is enabled: Removes all visible tags with the same value as the given checkbox item.

    Parameters

    • item: JQuery<HTMLElement>

      Checkbox item that was unchecked.

    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

  • renderItems(): void
  • Creates the individual checkboxes for each selectable option in the overlay panel.

    Returns void

  • renderLabel(): void
  • Create the label to display values

    Returns void

  • renderPanel(): void
  • Creates the overlay panel with the checkboxes for the selectable option.

    Returns void

  • resetValue(silent?: boolean): void
  • Resets the input.

    Parameters

    • Optional silent: boolean

      true to suppress triggering event listeners, or false otherwise.

    Returns void

  • selectValue(value: string): void
  • Checks the checkbox option with the given value.

    Parameters

    • value: string

      Value of the option to check.

    Returns void

  • setupFilterMatcher(): void
  • Finds and stores the filter function which is to be used for filtering the options of this select checkbox menu.

    Returns void

  • show(): void
  • Brings up the overlay panel with the available checkbox options.

    Returns void

  • startsWithFilter(value: string, filter: string): boolean
  • Implementation of a PrimeFaces.widget.SelectCheckboxMenu.FilterFunction that matches the given option when it starts with the given search text.

    Parameters

    • value: string

      Text of an option.

    • filter: string

      Value of the filter.

    Returns boolean

    true when the text of the options starts with the filter value, or false otherwise.

  • toggleItem(checkbox: JQuery<HTMLElement>, input: JQuery<HTMLElement>): void
  • Select or unselect the given checkbox option.

    Parameters

    • checkbox: JQuery<HTMLElement>

      One of the checkbox options of this widget to toggle.

    • input: JQuery<HTMLElement>

      (optional) input element representing the value of the checkbox

    Returns void

  • togglePanel(): void
  • Bring up the overlay panel if its not showing or hide it if it is showing.

    Returns void

  • toggleSelection(selectAll: boolean): void
  • Toggles either selecting all items or unselecting all items.

    Parameters

    • selectAll: boolean

      true to select all items and false to uncheck all items

    Returns void

  • unbindPanelEvents(): void
  • Unbind all panel event listeners

    Returns void

  • uncheck(checkbox: JQuery<HTMLElement>, updateInput: boolean): void
  • Unselects the given checkbox option.

    Parameters

    • checkbox: JQuery<HTMLElement>

      Checkbox option to unselect.

    • updateInput: boolean

      If true, update the hidden input field with the current value of this widget.

    Returns void

  • uncheckAll(silent?: boolean): void
  • Unselects all available options.

    Parameters

    • Optional silent: boolean

      true to suppress triggering event listeners, or false otherwise.

    Returns void

  • updateLabel(): void
  • When multi mode is disabled: Upates the label that indicates the currently selected item.

    Returns void

  • updateToggler(): void
  • Updates the select all / unselect all toggler so that it reflects the currently selected options.

    Returns void

Generated using TypeDoc