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

RemoteCommand provides a simple way to execute backing bean methods with javascript.

Sometimes you need to add a dynamic callback for when the remote command completes. Each remote command, when called, returns a promise-like object you can use for that purposes. Try opening a dev console and run the function "runRemoteCommand". See below for the code.

Ajax Tag Documentation

AjaxBehavior is an extension to standard f:ajax.

NameTypeRequiredDefaultDescription
async boolean false false When set to true, ajax requests are not queued.
delay String false If less than delay milliseconds elapses between calls to request() only the most recent one is sent and all other requests are discarded. If this option is not specified, or if the value of delay is the literal string 'none' without the quotes, no delay is used.
disabled boolean false false Disables ajax behavior.
event String false A String identifying the type of event the Ajax action will apply to. If specified, it must be one of the events supported by the component the Ajax behavior is being applied to. For HTML components this would be the set of supported DOM events for the component, plus "action" for Faces ActionSource components and "valueChange" for Faces EditableValueHolder components. If not specified, the default event is determined for the component. The DOM event name is the actual DOM event name (for example: "click") as opposed to (for example: "onclick").
form String false The enclosing form Form to serialize for an ajax request.
global boolean false true Global ajax requests are listened by ajaxStatus component, setting global to false will not trigger ajaxStatus.
ignoreAutoUpdate boolean false false If true, components which autoUpdate="true" will not be updated for this request. If not specified, or the value is false, no such indication is made.
ignoreComponentNotFound boolean false false If true, unresolvable components (ComponentNotFoundException) referenced in the update/process attribute are ignored.
immediate boolean false false Boolean value that determines the phaseId, when true actions are processed at apply_request_values, when false at invoke_application phase.
listener MethodExpression false Method to process in partial request.
oncomplete String false Client-side javascript callback to execute when ajax request is completed.
onerror String false Client-side javascript callback to execute when ajax request fails.
onstart String false Client-side javascript callback to execute before ajax request begins.
onsuccess String false Client-side javascript callback to execute when ajax request succeeds.
partialSubmit boolean false false Enables serialization of values belonging to the partially processed components only.
partialSubmitFilter String false Selector to use when partial submit is on, default is ":input" to select all descendant inputs of a partially processed components.
process String false Component(s) to process in partial request.
resetValues boolean false false If true, local values of input components to be updated within the ajax request would be reset.
skipChildren boolean false true Containers components like, datatable, panel, tabview skip their children if the request owner is them. For example, sort, page event of a datatable. As children are skipped, input values get lost, assume a case with a datatable and inputs components in a column. Sorting the column discards the changes and data is sorted according to original value. Setting skipChildren to false, enabled input values to update the value and sorting to be happened with user values.
timeout int false 0 Timeout in milliseconds for ajax request, whereas 0 means no timeout.
update String false Component(s) to update with ajax.
Loading...
Tag DocumentationNew DocumentationNew Documentation Introduction Process PartialSubmit Selector Search Validation RemoteCommand Observer Poll Fragment Status Lifecycle Dropdown
Basic

Execute a simple remote command by calling a javascript function.

Parameters

Passing parameters to the remote method as a javascript object or array of objects.

Receive Values Back

Receiving values form the server as a serialized json object.

Usage


<div class="card">
    <h:form>
        <p:remoteCommand name="rc" update="msgs" action="#{remoteCommandView.execute}"/>

        <p:remoteCommand name="rc2" update="msgs" action="#{remoteCommandView.execute}"
                         oncomplete="PF('msgsWidget').renderMessage({severity: 'info', summary: 'Data Received', detail: args.serverTime})"/>

        <h5>Basic</h5>
        <p>Execute a simple remote command by calling a javascript function.</p>
        <p:commandButton type="button" value="Send" icon="pi pi-refresh" onclick="rc()"/>

        <h5>Parameters</h5>
        <p>Passing parameters to the remote method as a javascript object or array of objects.</p>
        <p:commandButton type="button" value="Send Array" icon="pi pi-refresh" styleClass="mr-2"
                onclick="rc([{name: 'param1', value: 'foo'}, {name: 'param2', value: 'bar'}])"/>
        <p:commandButton type="button" value="Send Object" icon="pi pi-refresh"
                onclick="rc({param1: 'foo', param2: 'bar'})"/>

        <h5>Receive Values Back</h5>
        <p>Receiving values form the server as a serialized json object.</p>
        <p:commandButton type="button" value="Send" icon="pi pi-refresh" onclick="rc2()"/>

        <script>
            function runRemoteCommand(param1, param2) {
                var promise = rc([{name: 'param1', value: param1}, {name: 'param2', value: param2}]);
                promise.then(function (responseData) {
                    var serverTime = responseData.jqXHR.pfArgs.serverTime;
                    console.log("Request successful, returned server time is", serverTime);
                }).catch(function (error) {
                    console.error("Request failed", error);
                });
            }
        </script>

        <p:growl id="msgs" showDetail="true" skipDetailIfEqualsSummary="true" widgetVar="msgsWidget" />
    </h:form>
</div>