Locale

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

Input Style

Free Themes

Built-in component themes created by the PrimeFaces Theme Designer.

Saga Saga
Vela Vela
Arya Arya

Legacy Free Themes

Luna Amber Luna Amber
Luna Blue Luna Blue
Luna Green Luna Green
Luna Pink Luna Pink
Nova Nova
Nova Nova Alt
Nova Nova Accent

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.

Basic

Execute a simple remote command by calling a javascript function.

Parameters

Passing parameters to the remote method as a javascript object.

Receive Values Back

Receiving values form the server as a serialized json object.


<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.</p>
        <p:commandButton type="button" value="Send" icon="pi pi-refresh"
                onclick="rc([{name: 'param1', value: 'foo'}, {name: 'param2', value: '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>