Hi, I need help with the following:
I have a web form and I added a button the dynamically add comments to the form and be able to save the comment, the person who added it and the date the comment was added.
Actually when I do that, the form add the comment and close the window without leting me to continue.
Does any body has an idea of how to do this in a better way?
Thanks,
Sunny 
Subject: Two ways…
You could use XPages, but since you are positing in the 8.0 forum, I assume that you are on that version, meaning you can’t do that.
The other solution is to build the functionality yourself, using Javascript. It is actually not hard, especially not if you use jQuery. I am actually doing almost exactly what you describe in a web application I am working on.
What you do is to make the button a regular HTML button. Then you use the jQuery click event to execute some code.
That code should:
-
Hide the comment button
-
Display the comment input field and the submit button
The submit button also have jQuery code attached to it. That code will perform an Ajax call to an agent on the Domino server, which will create a comment document (linked to the main document with a key, for example the UniversalID).
The agent will also return the HTML to display all comments for the specified document. You use the callback function of the Ajax call to replace the content of the comment DIV with the HTML returned back from the agent.
Finally you hide the comment field and submit button, and unhide the comment button.
The only other thing you have to do is to call either the same agent (but without comment text) or a separate agent when the document is loaded. The agent should then return the HTML for all comments, without creating a comment document.
Soimething like this:
var commentText$(“#CommentInputField”).val();
$.ajax({
url: "/database.nsf/CreateComment?OpenAgent",
data: {"UNID":"universalid goes here","Comment":commentText},
dataType: "html",
cache: false
}).done(function(data) {
$('#commentInputSection').hide();
$('#commentCreateButton').show();
$('#commentSection').html(data);
});
Subject: I did it this way but still it close the window on me
//var frm = document.forms[0];if(confirm(“Comments will be added to the History. Click OK to continue.”)){
frm().WebFlag.value = "AddComment";
frm().submit();
this.disabled = true;
}
webflag storage the agent that actually add the comment, this part is working, what I need to do is to add the comment and some how not close the window.
Subject: Not sure if you can…
The submit will close the window, and send you to the page/URL specified in $$Return. You might be able to have that field set to the document you are on.
But I would suggest rewriting it the way I suggested, not using the built-in functionality.
Subject: It worked!!!
I did this, following your advise.
I put this validation in my $$Return field, the URL is a variable that I have setup to return to the current document. Thanks for your help
@If(WebFlag=“AddComment”;
“[” + theURL + “]”;
@Return(“<script LANGUAGE="JavaScript1.2" TYPE="text/javascript">if(opener){opener.location.reload(true)};window.close();”))