Provided you are using Primefaces and its brilliant addon Primefaces Extensions, then you could solve your problem in a following fashion:
XHTML
<pe:remoteCommand id="myCommand" name="sendPerson" process="@this" actionListener="#{myBean.myAction}">
<pe:methodSignature parameters="java.lang.String, com.yourproject.model.Person" />
<pe:methodParam name="headline"/>
<pe:methodParam name="person">
<pe:convertJson />
</pe:methodParam>
</pe:remoteCommand>
<script type="text/javascript">
var headline = 'This is demo';
person = {
name: 'John',
surname: 'Doe',
age: 30,
profession: 'Ventriloquist'
};
</script>
<p:commandButton value="Submit Person" type="button" onclick="sendPerson(headline, JSON.stringify(person))" />
Your bean would need two properties String ,a com.yourproject.model.Person Object that has all the properties that JavaScript object has - 3 Strings and an int and a method that takes those two params:
Bean
private String headline;
private Person person;
public void myAction(final String headline, final Person person) {
System.out.println(headline + " " + person);
}
Setters/Getters
Here's the link Primefaces Extensions MethodParam