Activiti外置表单的简单实现

这里只做演示,先写两个表单
start.jsp

<div>
	<span style="color: green;">开始表单: <input type="text" name="days" /></span>
</div>

task.form

<div>
	<span style="color: red;">任务表单: ${days}</span>
</div>

测试类:

  @Test
    public void testOutFormTest() {

        //测试部署
        RepositoryService repositoryService = activitiRule.getRepositoryService();
        Deployment deploy = repositoryService
                .createDeployment().name("测试外置表单")
                .addClasspathResource("bpmn/my-process_out_form.bpmn20.xml")
                .addClasspathResource("form/start.jsp")
                .addClasspathResource("form/task.form")
                .deploy();

        //流程定义
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
                .deploymentId(deploy.getId()).singleResult();

        //启动流程并设置参数
        Map<String, String> properties = Maps.newHashMap();
        properties.put("days", "4");
        FormService formService = activitiRule.getFormService();
        formService.submitStartFormData(processDefinition.getId(), properties);

        Object form = formService.getRenderedStartForm(processDefinition.getId());
        LOGGER.info("表单内容 : ", form.toString());
        System.out.println(form.toString());

        Task task = activitiRule.getTaskService()
                .createTaskQuery().processDefinitionId(processDefinition.getId()).singleResult();
        Object taskForm = formService.getRenderedTaskForm(task.getId());
        LOGGER.info("表单内容 : ", taskForm.toString());
        System.out.println(taskForm.toString());

    }

猜你喜欢

转载自blog.csdn.net/qq_42046342/article/details/101756687