You need to describe some comments when submitting a task each time. For example, you need to describe the reason for asking for leave when submitting the leave process. If the leader rejects the request, you can annotate the reason for rejection.
1. Add comments
// Because the process user context object is thread-independent, you must set it at the desired position to ensure that the setting and obtaining operations are authentication in the same thread. setauthenticateduserid (usercontext. get (). getname (); // The Name Of The annotator must be written. Otherwise, you do not know the person information when viewing it. // Add the annotator taskservice. addcomment (taskid, null, comment); // comment is the annotation content // complete taskservice. complete (taskid, vars); // vars is a variable.
2. Obtain the annotation content
Public list <comment> getprocesscomments (string taskid) {list <comment> historycommnets = new arraylist <> (); // 1) obtain the ID of the Process instance task = This. taskservice. createtaskquery (). taskid (taskid ). singleresult (); processinstance Pi = runtimeservice. createprocessinstancequery (). processinstanceid (task. getprocessinstanceid ()). singleresult (); // 2) query all historical activity lists (User Task Type) through the process instance
3. Display comments when preparing the task form page (put the list above into the value stack and traverse it using the struts2 tag)
<! -- Display all the comments, for example, Zhang San: Hello, Li Si: You are also good --> <s: iterator value = "# comments"> <s: date name = "time" format = "yyyy-mm-dd hh: mm"/> <br/> <s: property value = "userid"/>:< s: property value = "fullmessage"/> <br/> </S: iterator>