I tried the previous solutions with primefaces 4.0 but they didn't work for me.
So as a workaround I had to put a <h:inputHidden>
and set the value to a property of a ManagedBean,
and just before calling the <p:remoteCommand>
I set the value of this h:inputHidden (using jQuery) and call the p:remoteCommand (with making sure the remote command is processing the h:inputHidden)
FormBean.java
@ManagedBean(name = "formBean")
@ViewScoped
public class FormBean {
private String myValue;
public String getMyValue() {
return myValue;
}
public void setMyValue(String myValue) {
this.myValue = myValue;
}
public void remoteAction() {
someAction(myValue);
}
}
form.xhtml
.....
<p:remoteCommand name="remoteAction" actionListener="#{formBean.remoteAction()}" process="@this myValueHidden" />
<h:inputHidden id="myValueHidden" value="#{formBean.myValue}" />
.....
form.js
function onClickOfSomeButton() {
$('#formName\\:myValueHidden').val('myValue test value');
remoteAction();
}
EDIT
Also this works perfectly..
remoteAction([{name: 'name1', value: 'value1'}, {name: 'name2', value: 'value2'}]);
Hope this helps...