score:7

Accepted answer

in the example below the the p:commandbutton starts the ajax request. the json object you want to use can be stored in the h:inputhidden field. when the p:commandbutton completes the javascript function is called to update the chart. the javascript function will be able to access the json object from the h:inputhidden field.

xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <h:head>
        <script type="text/javascript">           
            function dosomething() {
                var value = jquery("#beanvalue").attr('value');
                alert(value);
            }
        </script>
    </h:head>
    <h:body>
        <h:form prependid="false" >
            <p:commandbutton value="update" action="#{testbean.update}" update="beanvalue" oncomplete="dosomething();" />
            <h:inputhidden value="#{testbean.output}" id="beanvalue"  />
        </h:form>
    </h:body>
</html>

bean

import javax.faces.bean.managedbean;
import javax.faces.bean.viewscoped;

@managedbean
@viewscoped
public class testbean {

    private string output;

    public testbean() {
        output = "1";
    }

    public void update() {
        output += "1";
    }

    public string getoutput() {
        return output;
    }

    public void setoutput(string output) {
        this.output = output;
    }
}

Related Query

More Query from same tag