• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

Ajax Framework Callback

Callback executes JavaScript on an event of a component instead of an AJAX request. Like p:ajax it is attached to an event of the component, the JavaScript gets source, event, params and ext. Returning false stops the following behaviors of the event, e.g. a p:ajax.

Callback Tag Documentation

Callback executes JavaScript on an event of the component instead of an AJAX request like p:ajax.

NameTypeRequiredDefaultDescription
disabled boolean false false Disables the callback.
event String false Event of the component that executes the JavaScript, the default event of the component if not set.
execute String false JavaScript to execute, the body of a function with the arguments source (client id of the component), event (name of the event), params (parameters of the event) and ext. Returning false stops the following behaviors of the event.
Loading...
Tag Documentation Documentation Documentation Introduction Process PartialSubmit Selector Search Validation RemoteCommand Observer Callback Poll Fragment Status Lifecycle Dropdown
Basic
Event Parameters

The slideEnd event passes the value of the slider in params.

Before p:ajax

The AJAX request is only sent if the callback does not return false.

Usage


<p:growl id="growl" showDetail="true"/>

<h:form>
    <div class="card">
        <h5 class="mt-0">Basic</h5>
        <p:selectOneMenu id="city" widgetVar="cityMenu" styleClass="mr-3">
            <f:selectItem itemLabel="Berlin" itemValue="Berlin"/>
            <f:selectItem itemLabel="Paris" itemValue="Paris"/>
            <f:selectItem itemLabel="Rome" itemValue="Rome"/>
            <p:callback event="change"
                        execute="document.getElementById('basicOutput').textContent = event + ' of ' + source + ': ' + PF('cityMenu').getSelectedValue();"/>
        </p:selectOneMenu>
        <span id="basicOutput"></span>
    </div>

    <div class="card">
        <h5 class="mt-0">Event Parameters</h5>
        <p class="mt-0">The <i>slideEnd</i> event passes the value of the slider in <i>params</i>.</p>
        <p:inputText id="sliderInput" styleClass="mb-3"/>
        <p:slider for="sliderInput" styleClass="w-20rem">
            <p:callback event="slideEnd"
                        execute="document.getElementById('sliderOutput').textContent = 'Slide ended at ' + params[0].value;"/>
        </p:slider>
        <p id="sliderOutput" class="mb-0"></p>
    </div>

    <div class="card">
        <h5 class="mt-0">Before p:ajax</h5>
        <p class="mt-0">The AJAX request is only sent if the callback does not return <i>false</i>.</p>
        <p:toggleSwitch value="#{callbackView.active}">
            <p:callback event="change" execute="return confirm('Send the AJAX request?');"/>
            <p:ajax listener="#{callbackView.onChange}" update="growl"/>
        </p:toggleSwitch>
    </div>
</h:form>