Reputation: 495
I pass the values to managedbean using JSON and remotecommand but when I try to see the managed bean's value in JavaScript I see the default value not the updated value.
I do not want to refresh the page or use hidden tags in XHTML as I might need much data exchange.
When the value changed:
<script>
var json= [ { name : 'zoom', value : zoomLevel } ];
sendParams(json);
</script>
in my .js file I use remotecommand:
function sendParams(jsonData) {
passToJSFManagedBean (jsonData);
}
in .xhtml I call the function in the managedbean:
<p:remoteCommand name="passToJSFManagedBean" id="passToJSFManagedBeancmd" action="#{tagBean.setParams}" process="@this" />
in managed bean:
public void setParams() {
this.zoom= Integer.parseInt(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("zoom"));
System.out.println("Zoom level: "+zoom);
}
Then we could see the value passed managed bean. But when I try in js the zoom value is not updated and has the default value.
alert('#{tagBean.zoom}');
Is there any way to get managed bean's properties in javascript without using hidden tags in xhtml ? Important is that the Page dose not need to refresh. Is it possible to use remotecommand to get managedbean values? Thanks for help.
Upvotes: 1
Views: 1159