目前Activiti默认支持的类型有String,long,enum,date,boolean,collection

要自定义字段类型,首先需要表单类型解析类

/**
* @Author:LJ
* @Description: activiti Javascript类型表单字段
* @Date: 2018/5/17
* @Modified By:
*/
public class JavascriptFormType extends AbstractFormType {
/**
* 把表单中的值转换为实际的对象
* @param propertyValue
* @return
*/
@Override
public Object convertFormValueToModelValue(String propertyValue) {
return propertyValue;
} /**
* 把实际对象的值转换为表单中的值
* @param modelValue
* @return
*/
@Override
public String convertModelValueToFormValue(Object modelValue) {
return (String) modelValue;
} /**
* 定义表单类型的标识符
*
* @return
*/
@Override
public String getName() {
return "javascript";
}
}

第二、在流程引擎中注册解析类

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
....
<!-- 自定义表单字段类型 -->
<property name="customFormTypes">
<list>
<bean class="me.kafeitu.activiti.form.JavascriptFormType" />
</list>
</property>
</bean>
</beans>

扩展:SpringBoot方式注册解析

package com.example.demo.config;

import com.example.demo.config.formType.JavascriptFormType;
import org.activiti.engine.form.AbstractFormType;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import java.util.Arrays;
import java.util.List; /**
* @Author:LJ
* @Description:
* @Date: 2018/3/21
* @Modified By:
*/
@Configuration
public class ApplicationConfig extends WebMvcConfigurerAdapter {/**
* 方式一
*@Author LJ
*/
@Bean
public BeanPostProcessor activitiConfigurer() {
return new BeanPostProcessor() {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof SpringProcessEngineConfiguration) {
List<AbstractFormType> customFormTypes = Arrays.<AbstractFormType>asList(new JavascriptFormType());
((SpringProcessEngineConfiguration)bean).setCustomFormTypes(customFormTypes);
}
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
}; }
}

参考:

How to declare an Activiti custom FormType in a Spring Boot application

activiti实战系列之动态表单 formService 自定义变量类型的更多相关文章

  1. Flowable实战(五)表单和流程变量

    一.流程变量   流程实例按步骤执行时,需要保存并使用一些数据,在Flowable中,这些数据称为变量(variable).   流程实例可以持有变量,称作流程变量(process variables ...

  2. 2017.2.28 activiti实战--第六章--任务表单(一)动态表单

    学习资料:<Activiti实战> 第六章 任务表单(一)动态表单 内容概览:本章要完成一个OA(协同办公系统)的请假流程的设计,从实用的角度,讲解如何将activiti与业务紧密相连. ...

  3. antd+vue3实现动态表单的自动校验

    由于vue3用的人还不多,所以有些问题博主踩了坑只能自己爬出来了,特此做个记录.如有错误,请大家指正. 回归正题,我所做的业务是,动态添加表单项,对每一项单独做校验,效果如下: 主要代码如下: 1 & ...

  4. vue 开发系列(八) 动态表单开发

    概要 动态表单指的是我们的表单不是通过vue 组件一个个编写的,我们的表单是根据后端生成的vue模板,在前端通过vue构建出来的.主要的思路是,在后端生成vue的模板,前端通过ajax的方式加载后端的 ...

  5. Angular动态表单生成(八)

    动态表单生成之拖拽生成表单(下) 我们的动态表单,最终要实现的效果与Form.io的在线生成表单的效果类似,可以参考它的demo地址:https://codepen.io/travist/full/x ...

  6. Angular动态表单生成(六)

    动态表单之根据Json生成表单 我们在实际的使用中,动态表单往往是由服务器端的一系列配置,然后返回数据给客户端,最后客户端根据数据来动态的生成表单.那么怎么像我们上面所描述的这样,生成一个可以让我们的 ...

  7. Angular动态表单生成(五)

    动态表单生成之布局 到上面的篇章为止,我们已经把表单比较完整的生成出来了,也实现了一些验证功能,可以说,我们截止这里,就已经可以满足我们的大部分表单生成需求了~ 但是: 目前来说,我们对于表单的布局只 ...

  8. Flask开发系列之Web表单

    Flask开发系列之Web表单 简单示例 from flask import Flask, request, render_template app = Flask(__name__) @app.ro ...

  9. [K/3Cloud] 如何从被调用的动态表单界面返回数据

    在需要返回数据的地方调用表单返回方法完成数据返回 this.View.ReturnToParentWindow(retData); 在调用界面的回调函数中取出返回结果的ReturnData即可使用. ...

随机推荐

  1. C语言 分割字符串

    对指针的操作有点迷糊 只好采用下面一些比较low的手段 char str[100]; char delims[] = ";"; char *result = NULL; sprin ...

  2. js,jq获取父,兄弟,子节点整理

    js获取节点 父: parentNode 获取已知节点的父节点. 子: childNodes; 得到全部子节点 children 得到全部子节点 firstChild 获得第一个子节点 lastChi ...

  3. hive表的存储路径查找以及表的大小

    1.在hive中知道一个表的存储路径可以通过hive命令   desc formatted table_name 显示表的详细信息; 2.然后找到该表的存储路径 "Location:    ...

  4. Vue项目中如何使用Element-UI以及如何使用sass

    Vue项目中如何使用Element-UI以及如何使用sass 当我们在开发Vue项目的时候通常会选择Element-UI作为我们的UI框架,其官方中文文档地址是http://element.eleme ...

  5. servlet中为什么doGet方法没有被调用的一种可能(笔记)

    创建了一个servlet,然后在doGet()方法内写一些简单的测试语句,但是在实际运行中发现并没有调用到doGet()方法,后来发现自己在创建servlet是将service()方法也勾选上去了,而 ...

  6. 《剑指offer》第五十八题(左旋转字符串)

    // 面试题58(二):左旋转字符串 // 题目:字符串的左旋转操作是把字符串前面的若干个字符转移到字符串的尾部. // 请定义一个函数实现字符串左旋转操作的功能.比如输入字符串"abcde ...

  7. 查询选修了全部课程的学生姓名_如何解?-MS-SQLServer/应用实例

    查询选修了全部课程的学生姓名:student 是学生表 course 是选课表 sc 是课程表select snamefrom studentwhere not exists(select *from ...

  8. [C#]创建表格(.xlsx)的典型方法

    Time:2017-10-11   10:12:13 利用EPPlus(4.1): 下载引用地址:http://epplus.codeplex.com/ --EPPlus is a .net libr ...

  9. (10)进程---Manager数据共享

    Manager  能够实现进程之间的数据共享(dict list),但是必须上锁来确保数据的准确性, 队列则可以实现进程之间数据通信 from multiprocessing import Proce ...

  10. Linux 各种软件的安装-mediawiki + wordpress篇

    php apache mysql 三剑客安装好后,可以愉快地安装一些成熟的web应用啦,比如wordpress可以当做自己的笔记本,mediawiki整理知识库. 首先是mediawiki,网上说不错 ...