It's all about the answers!

Ask a question

Java Server Side : How check if a comment has been add


Antoine LELEU (5012728) | asked May 14 '13, 11:22 a.m.
 
Hello,

I'm coding a  java plugin and i would like to know how check if a comment has been add during the saving...

Thanks for your help ?

Antoine


Accepted answer


permanent link
Lauren Hayward Schaefer (3.3k11727) | answered May 15 '13, 7:20 a.m.
JAZZ DEVELOPER
Hi Antoine,

I have code that adds a comment to a work item.  I've poked around it, and it looks like you could do something like the following before saving the work item with a new comment:

IComments comments= workItem.getComments();
int numberOfComments = comments.getContents().length;

Then after you save the work item, you could check that contents[numberOfComments].toString() is your comment.

I don't have an environment setup to see if getContents() is returning what I expect it will, so hopefully that will work for you (or at least get you started).
Antoine LELEU selected this answer as the correct answer

One other answer



permanent link
Antoine LELEU (5012728) | answered May 15 '13, 11:42 a.m.
 
Hi Lauren,

Thanks for your answer.

I tried your solution, i compared the "numberOfComments" betwen the old and new state during the saving and it works perfectly..

Thanks again !

Antoine

Comments
Lauren Hayward Schaefer commented May 15 '13, 11:57 a.m.
JAZZ DEVELOPER

I'm glad it worked for you!

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.