Activiti gets the exit of the current activity (task) (dynamic generation and submission button), activiti current

Source: Internet
Author: User

Activiti gets the exit of the current activity (task) (dynamic generation and submission button), activiti current

1. Set exit Variables

When a task has one or more exits, you can set judgment conditions on the egress links.

 

2. Obtain the export set based on the task Id.

Public List <String> getOutGoingTransNames (String taskId) {List <String> transNames = new ArrayList <> (); // 1. obtain the process definition Task = this. taskService. createTaskQuery (). taskId (taskId ). singleResult (); ProcessDefinitionEntity pd = (ProcessDefinitionEntity) repositoryService. getProcessDefinition (task. getProcessDefinitionId (); // 2. obtain the process instance ProcessInstance pi = runtimeService. createProcessInstanceQuery (). processInstanceId (task. getProcessInstanceId ()). singleResult (); // 3. find the ID String activitiId = pi of the current activity through the process instance. getActivityId (); // 4. activity ID is used to find the activity object ActivityImpl activity = pd in the process definition. findActivity (activitiId); // 5. use the activity object to find all the exits of the current activity List <PvmTransition> transitions = activity. getOutgoingTransitions (); // 6. extract the names of all exits and encapsulate them into a set for (PvmTransition trans: transitions) {String transName = (String) trans. getProperty ("name"); if (StringUtils. isNotBlank (transName) {transNames. add (transName) ;}} if (transNames. size () = 0) {transNames. add ("Submit"); // default} return transNames ;}

3. Applications

When the page is displayed, traverse the node exit and input the corresponding commit exit name when submitting

Code submission:

Map <String, Object> vars = new HashMap <> (); vars. put ("outcome", outcome); // outcome is the name of the submit button.
// Complete the task
TaskService. complete (taskId, vars );

 

      

 




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.