• 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

RemoteCommand

RemoteCommand executes backing bean methods and does a partial update, triggered by custom client side script. It can pass parameters with pe:assignableParam (assigned to bean properties) or pe:methodParam (arguments of a bean method).

RemoteCommand Tag Documentation

RemoteCommand provides a way to execute JSF backing bean methods directly from javascript.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
action MethodExpression false A method expression or a string outcome to process when command is executed.
actionListener ActionListener false An action listener to process when command is executed.
actionListenerMethodExpression MethodExpression false A method expression to invoke by polling.
async boolean false false When set to true, ajax requests are not queued.
autoRun boolean false false Whether to automatically run the JavaScript function when the page is loaded.
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.
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 When set true, process validations logic is executed at apply request values phase for this component.
name String false Name of the JavaScript function to create.
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.
timeout int false 0 Timeout in milliseconds for ajax request, whereas 0 means no timeout.
update String false Component(s) to update with ajax.
value Object false Value of the component.

AssignableParam Tag Documentation

AssignableParam can be used the apply a parameter of the RemoteCommand to a backing bean.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
assignTo ValueExpression true ValueExpression where the parameter will be applied.
converter Converter false EL expression resolves to a converter instance or literal converter ID defining a component converter.
name String true Name of the parameter.
value Object false Value of the component.

MethodParam Tag Documentation

Method can be used to receive a parameter of the RemoteCommand in the actionListener or action method.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
converter Converter false EL expression resolves to a converter instance or literal converter ID defining a component converter.
name String true Name of the parameter.
type String false Type of the parameter.
value Object false Value of the component.

MethodSignature Tag Documentation

Tag handler for methodSignature; comma-separated class names for RemoteCommand method parameters.

NameTypeRequiredDefaultDescription
parameters String true A comma separated list of fully qualified class names, matching passed parameters in order.
Tag Documentation
Basic Usage

A certain part of a page can be lazily loaded on demand.

Using AssignableParam

Assign JavaScript parameters to a property in a bean with pe:remoteCommand and pe:assignableParam. AssignableParam specifies a name of the parameter and an EL expression for the corresponding setter the parameter is applied to (assignTo). A converter can be attached as a child or with the converter attribute.



- - -

Using MethodParam

Call a remote Java method with any parameters from JavaScript with pe:remoteCommand, pe:methodParam and pe:methodSignature. MethodParam specifies the name of a parameter and MethodSignature a comma separated list of fully qualified class names, in the same order as the passed parameters.

Usage


<div class="card">
    <h5>Basic Usage</h5>
    <p>A certain part of a page can be lazily loaded on demand.</p>
    <h:form id="formBasicUsage">
        <p:commandButton value="Load" type="button" onclick="lazyload()" style="margin-bottom: 10px;"/>
        <p:outputPanel id="lazypanel" layout="block">
            <h:outputText
                    value="This part of page is lazily loaded on demand using a RemoteCommand"
                    rendered="#{requestScope.shouldRender}"/>
        </p:outputPanel>
        <pe:remoteCommand name="lazyload" update="lazypanel">
            <f:setPropertyActionListener value="#{true}"
                                         target="#{requestScope.shouldRender}"/>
        </pe:remoteCommand>
    </h:form>
</div>

<div class="card">
    <h5>Using AssignableParam</h5>
    <p>Assign JavaScript parameters to a property in a bean with <code>pe:remoteCommand</code> and <code>pe:assignableParam</code>.
        AssignableParam specifies a <code>name</code> of the parameter and an EL expression for the corresponding setter the parameter
        is applied to (<code>assignTo</code>). A converter can be attached as a child or with the <code>converter</code> attribute.</p>
    <h:form id="formAssignableParam">
        <p:growl id="growl" showDetail="true"/>

        <pe:remoteCommand id="assignDataCommand" name="assignData" process="@this" update="subject date circle growl"
                          actionListener="#{remoteCommandController.parametersAssigned}">
            <pe:assignableParam name="subject" assignTo="#{remoteCommandController.subject}"/>
            <pe:assignableParam name="date" assignTo="#{remoteCommandController.date}">
                <f:convertDateTime type="both" pattern="MM/dd/yyyy HH:mm:ss"/>
            </pe:assignableParam>
            <pe:assignableParam name="circle" assignTo="#{remoteCommandController.circle}">
                <pe:convertJson/>
            </pe:assignableParam>
        </pe:remoteCommand>

        <script type="text/javascript">
            var assignCircle = {
                radius: 50,
                backgroundColor: "#FF0000",
                borderColor: "#DDDDDD",
                scaleFactor: 1.2
            };
            var assignCircle2 = {
                radius: 32,
                backgroundColor: "#FF0320",
                borderColor: "#DDFFFD",
                scaleFactor: 1.6
            };
        </script>

        <h:outputLabel for="subject" value="Subject: "/>
        <h:outputText id="subject" value="#{remoteCommandController.subject}"/>
        <br/>
        <h:outputLabel for="date" value="Date: "/>
        <h:outputText id="date" value="#{remoteCommandController.date}"/>
        <br/>
        <h:outputLabel for="circle" value="Circle: "/>
        <h:outputText id="circle"
                      value="#{remoteCommandController.circle.radius} - #{remoteCommandController.circle.backgroundColor} - #{remoteCommandController.circle.borderColor} - #{remoteCommandController.circle.scaleFactor}"/>
        <br/><br/>

        <p:commandButton value="Apply Data" type="button" onclick="assignData('hello world', '05/14/2007 12:55:42', JSON.stringify(assignCircle))"/>
        <p:commandButton value="Apply Second Data" type="button" onclick="assignData('hello user', '07/11/2001 11:55:42', JSON.stringify(assignCircle2))"/>
    </h:form>
</div>

<div class="card">
    <h5>Using MethodParam</h5>
    <p>Call a remote Java method with any parameters from JavaScript with <code>pe:remoteCommand</code>, <code>pe:methodParam</code>
        and <code>pe:methodSignature</code>. MethodParam specifies the <code>name</code> of a parameter and MethodSignature a comma
        separated list of fully qualified class names, in the same order as the passed parameters.</p>
    <h:form id="formMethodParam">
        <p:growl id="growl" showDetail="true"/>

        <pe:remoteCommand id="callMethodCommand" name="callMethod" process="@this" update="growl"
                          actionListener="#{remoteCommandController.printMethodParams}">
            <pe:methodSignature parameters="java.lang.String, java.util.Date, org.primefaces.extensions.showcase.model.Circle"/>
            <pe:methodParam name="subject"/>
            <pe:methodParam name="date">
                <f:convertDateTime type="both" pattern="MM/dd/yyyy HH:mm:ss"/>
            </pe:methodParam>
            <pe:methodParam name="circle">
                <pe:convertJson/>
            </pe:methodParam>
        </pe:remoteCommand>

        <script type="text/javascript">
            var methodCircle = {
                radius: 50,
                backgroundColor: "#FF0000",
                borderColor: "#DDDDDD",
                scaleFactor: 1.2
            };
            var methodCircle2 = {
                radius: 32,
                backgroundColor: "#FF0320",
                borderColor: "#DDFFFD",
                scaleFactor: 1.6
            };
        </script>

        <p:commandButton value="Apply Data" type="button" onclick="callMethod('hello world', '05/14/2007 12:55:42', JSON.stringify(methodCircle))"/>
        <p:commandButton value="Apply Second Data" type="button" onclick="callMethod('hello user', '07/11/2001 11:55:42', JSON.stringify(methodCircle2))"/>
    </h:form>
</div>