public AjaxRequestBuilder onsuccess(String onsuccess) {
        if (onsuccess != null) {
            buffer.append(",onsu:function(data,status,xhr){").append(onsuccess).append(";}");
        }

        return this;
    }
Helper to generate javascript code of an ajax call
primefaces/src/main/java/org/primefaces/util/AjaxRequestBuilder.java