piątek, 15 kwietnia 2016

piątek, 8 kwietnia 2016

PrimeFaces remoteCommand with parameters

HTML view:
<p:remoteCommand name="remoteCommandName" actionListener="#{mBean.remoteCommandActionlistener}" />
Backing bean code:
public void remoteCommandActionlistener() {
  String param1 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("param1");
  String param2 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("param2");
  System.out.println("param1: " + param1 + ", param2: " + param2);
}
JavaScript call:
remoteCommandName([{name: 'param1', value: 'value1'}, {name: 'param2', value: 'value2'}])