I am trying to invoke the primefaces commanlink via javascript and want to know whether it executed successfully or not and if it is successful i need to get the values which sent by callbackfunction. I am capturing the return value of the commandlinke which is a bunch of javascript. How to get the args(topicComment) value in my senario. I think i can do a workaround by setting few more hidden fields, but i want to see how to get it directly.
Javascript
$('.postButton').livequery("click", function (){
var comment_content = $(this).parent().siblings().children('textarea').val();
$('#topic_comment').val(comment_content);
var object=$('#postCmdLink').click();
var output;
for (property in object) {
output += property + ': ' + object[property]+'; ';
}
console.log(output);
}
Server side
public void addComment(){
.................................
context = RequestContext.getCurrentInstance();
context.addCallbackParam("topicComment", topicBean.getTopicCommentVO().getTopicCommentGuid());
}
Instead of clicking
CommandLinkby jQuery:Uses Primefaces AjaxAPI to call ajax and register a callback to get the result:
Primefaces User documentation 3.1.1 section
7.2 Ajax APIpage 454.