RemoteCommand (<b:remoteCommand />)since 1.0.1

The <b:remoteCommand> is an invisible component allowing you to call a Java backend method from JavaScript.

Basic usage

The API of <b:remoteCommand> resembles the <b:commandButton>, the PrimeFaces <p:remoteCommand>) or the <o:commandScript /> of OmniFaces.


You've triggered the remoteCommand 0 times.

Parameters

To pass one or more parameter, simply declare them in the attribute parameters just the way you want to see them defined in the generated JavaScript function. E.g.

  • <b:remoteCommand name="setCounter" parameters="initialValue" /> generates the JavaScript function setCounter(initialValue).
  • <b:remoteCommand name="setCounter" parameters="initialValue,step" /> generates the JavaScript function setCounter(initialValue,step).

Implicit parameter "event"

The last parameter is always the event. This parameter is added automatically to the parameter list. It's necessary to call an AJAX request and it's useful in many other situations. It's a good idea to pass the event when you're calling the function, even though the AJAX engine usually also works without it. In this case, the event passed to the AJAX engine is undefined, which may or may not cause problems.


You've set the remoteCommand counter to 0.

Reference section

Attribute Default value Description
action (none) The button action, this can be method expression or a string outcome.
action-listener
actionListener (alternative writing)
(none) A method expression that refers to a method with this signature: void methodName(Action-Event).
ajax false Whether the Button submits the form with AJAX.
binding (none) An EL expression referring to a server side UIComponent instance in a backing bean.
delay (none) Delays the AJAX request.
disabled false Boolean value to specify if the button is disabled.
id (none) Unique identifier of the component in a namingContainer.
immediate false Flag indicating that, if this component is activated by the user, notifications should be delivered to interested listeners and actions immediately (that is, during Apply Request Values phase) rather than waiting until Invoke Application phase. Default is false.
name (none) Name of the JavaScript function.
onclick (none) The onclick attribute.
oncomplete (none) JavaScript to be executed when ajax completes.
onerror (none) JavaScript to be executed when ajax results on an error (including both network errors and Java exceptions).
onsuccess (none) JavaScript to be executed when ajax completes with success (i.e. there's neither a network error nor a Java exception).
parameters (none) Optional list of parameters to be added to the parameter list of the JavaScript function. The JSF bean can read these parameters from the request parameters (FacesContext.getCurrentContext.getRequestParameter('name1')). If you need more than one parameter, separate them with commas. Don't add a type because this is the signature of the JavaScript function.
process (none) Comma or space separated list of ids or search expressions denoting which values are to be sent to the server.
rendered false Boolean value to specify the rendering of the component, when set to false the component will not be rendered.
update (none) Component(s) to be updated with ajax.