Add this array (JSON will be better) as the value of the field of your managed bean, and then set it to <h:inputHidden/> , which you can execute, and execute it via <f:ajax/> to send and receive data
<h:inputHidden id="verticesHiddenContainer" value="#{yourBean.vertices}" />
Then your bean should have both a setter and a getter for it. If you decide to send it as JSON, I suggest you use Gson (since you are already on Google sites) to analyze it.
The procedure will be something like this:
First of all, you create vertices JSON that combines the data you want to send to the server, then you set it to hidden input. I use jQuery, but if you use simple javascript, you have to do the same, but use document#getElementById instead:
var vertices =
Then execute the hidden component with f:ajax and commandLink , for example:
<h:commandLink value="Send data to server" action="#{yourBean.process}" > <f:ajax execute="verticesHiddenContainer" /> </h:commandLink>
Now the link activates the ajax request, which updates the field in the bean with the input current value. Remember that as you go through JSON, you will have to parse it. Pretty simple if you use Gson:
public void setVertices(String verticesString) {
SO already has great answers about serializing and parsing JSON. I suggest you take a look at them if you are in doubt:
source share