Reputation: 1355
I am trying to pass bean values to javascript code after ajax update but it doesn't work.
<p:commandButton action="#{bean.transactionStarted}" onclick="userclicked(xhr,args,status)"/>
And the backing bean adds the value via:
RequestContext.getCurrentInstance().addCallbackParam("message", "message");
When I debug I am seeing upper statement executed correctly but it does not arrive to js and it is not alerting:
function userclicked(xhr, status, args) {
alert(args.message);
}
Upvotes: 0
Views: 135
Reputation: 26
Because onclick
was called before backing bean
method completed. You should wait until it finishes. Use oncomplete
, as follows:
<p:commandButton action="#{bean.transactionStarted}" oncomplete="userclicked(xhr,args,status)"/>
Upvotes: 1