Try this
I use primefaces 4.0, ViewScope, Ajax request.
With p:component obtain the ClientId of p:messages atributte for="someComponent" and pass this value to bean through p:remoteCommand, later you can set the message from bean with ClientId.
In some element add this
onclick="rc([{name:'index',value:#{item.index}},{name:'msg1',value:'#{p:component('someComponent')}'}])"
Create p:remoteCommand to set the id
<p:remoteCommand process="@this" name="rc" action="#{bean.someMethod}"/>
public void someMethod(){
FacesContext context = FacesContext.getCurrentInstance();
Map<String,String> params = context.getExternalContext().getRequestParameterMap();
int index=Integer.parseInt(params.get("index"));
this.msg[index]=params.get("msg1");
}
Now you can set messages from bean:
FacesContext.getCurrentInstance().addMessage(this.msg[x], new FacesMessage(FacesMessage.SEVERITY_ERROR,null,"someMessage"));