I am trying to pass a parameters with
p:remoteCommand
Unfortunately when I retrieve the paramer in my bean method I always get null.
Is there anything wrong with my code?
Here is my page code:
<a href="#" onclick="rc([{'d':'01'}])">01</a>
<p:remoteCommand name="rc" update=":myform:messages" actionListener="#{mybean.changedaybar}" />
and this is the bean method:
public void changedaybar() {
Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String param = params.get("d");
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Executed"+param, "Using RemoteCommand."));
}
Which PrimeFaces version are you using? It's important because the way to pass parameters from a JavaScript function to a
p:remoteCommand
has changed in PrimeFaces 3.3.You will see the correct syntax in the following post: https://stackoverflow.com/a/18510102/2118909 but for your convenience here is the summary.
From PrimeFaces 3.3
Before PrimeFaces 3.3