activiti自定义流程之自定义表单(一):环境配置

先补充说一下自定义流程整个的思路,自定义流程的目的就是为了让一套代码解决多种业务流程,比如请假单、报销单、采购单、协作单等等,用户自己来设计流程图。

这里要涉及到这样几个基本问题,一是不同的业务需求,流程节点不一样,流程中的任务多少不一样,因此后台就必须解决这个逻辑处理上的问题,要能同一套代码实现动态任务数量的处理。

二是不同的业务各种字段叫法也不一样,各个节点对应的页面也应该不一样,例如请假单就需要请假申请人、请假天数、请假原因等字段,而报销单可能就是报销申请人、报销金额、报销原因、报销凭证等;申请页面要对应填写申请信息的页面,处理也面要对应处理任务的页面,不同业务之间自然也会有区别,因此就需要前台能够自定义表单,用户自己来设计需要的页面。

三就是怎样把后台自定义和前台的自定义关联起来正确的交互。

因此,遵循这一思路,我就分成这样三个步骤来着手,之前的学习中就着重解决了后台逻辑适应不同数量任务的问题。那么接下来就是第二步,实现前台的自定义表单,我在工作中并不做前台,因此实现的过程也就是只求功能实现,不求其他。

在自定义表单中,使用到了ueditor表单设计器插件,
下载:http://formdesign.leipi.org/downloads.html#java
集成插件参考文档: http://formdesign.leipi.org/doc.html
实际上我就是把解压后的文件中的js、css和index.html拿到了我的文件中进行修改使用,我的项目基本结构如下图,其中webapp中红线框起来的是自己加的文件目录,没有框起来的就是从插件中拿来的:

项目基本环境配置如下:
1、 maven导包相关配置文件pom.xml:

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  3. <modelVersion>4.0.0</modelVersion>
  4. <groupId>webFormTest</groupId>
  5. <artifactId>webFormTest</artifactId>
  6. <packaging>war</packaging>
  7. <version>0.0.1-SNAPSHOT</version>
  8. <name>webFormTest Maven Webapp</name>
  9. <url>http://maven.apache.org</url>
  10. <dependencies>
  11. <dependency>
  12. <groupId>junit</groupId>
  13. <artifactId>junit</artifactId>
  14. <version>4.11</version>
  15. </dependency>
  16. <dependency>
  17. <groupId>org.springframework</groupId>
  18. <artifactId>spring-beans</artifactId>
  19. <version>4.0.9.RELEASE</version>
  20. </dependency>
  21. <dependency>
  22. <groupId>org.springframework</groupId>
  23. <artifactId>spring-core</artifactId>
  24. <version>4.0.9.RELEASE</version>
  25. </dependency>
  26. <dependency>
  27. <groupId>org.springframework</groupId>
  28. <artifactId>spring-aop</artifactId>
  29. <version>4.0.9.RELEASE</version>
  30. </dependency>
  31. <dependency>
  32. <groupId>org.springframework</groupId>
  33. <artifactId>spring-context</artifactId>
  34. <version>4.0.9.RELEASE</version>
  35. </dependency>
  36. <dependency>
  37. <groupId>org.springframework</groupId>
  38. <artifactId>spring-webmvc</artifactId>
  39. <version>4.0.9.RELEASE</version>
  40. </dependency>
  41. <dependency>
  42. <groupId>org.springframework</groupId>
  43. <artifactId>spring-web</artifactId>
  44. <version>4.0.9.RELEASE</version>
  45. </dependency>
  46. <dependency>
  47. <groupId>org.springframework</groupId>
  48. <artifactId>spring-aspects</artifactId>
  49. <version>4.0.9.RELEASE</version>
  50. </dependency>
  51. <dependency>
  52. <groupId>org.springframework</groupId>
  53. <artifactId>spring-expression</artifactId>
  54. <version>4.0.9.RELEASE</version>
  55. </dependency>
  56. <dependency>
  57. <groupId>org.springframework</groupId>
  58. <artifactId>spring-tx</artifactId>
  59. <version>4.0.9.RELEASE</version>
  60. </dependency>
  61. <dependency>
  62. <groupId>javax.servlet</groupId>
  63. <artifactId>javax.servlet-api</artifactId>
  64. <version>3.1.0</version>
  65. </dependency>
  66. <dependency>
  67. <groupId>com.fasterxml.jackson.core</groupId>
  68. <artifactId>jackson-annotations</artifactId>
  69. <version>2.2.3</version>
  70. </dependency>
  71. <dependency>
  72. <groupId>com.fasterxml.jackson.core</groupId>
  73. <artifactId>jackson-core</artifactId>
  74. <version>2.2.3</version>
  75. </dependency>
  76. <dependency>
  77. <groupId>com.fasterxml.jackson.core</groupId>
  78. <artifactId>jackson-databind</artifactId>
  79. <version>2.2.3</version>
  80. </dependency>
  81. <dependency>
  82. <groupId>org.springframework</groupId>
  83. <artifactId>spring-context-support</artifactId>
  84. <version>4.0.9.RELEASE</version>
  85. </dependency>
  86. <dependency>
  87. <groupId><a href="http://lib.csdn.net/base/14" class="replace_word" title="MySQL知识库" target="_blank" style="color:#df3434; font-weight:bold;">mysql</a></groupId>
  88. <artifactId>mysql-connector-java</artifactId>
  89. <version>5.1.34</version>
  90. </dependency>
  91. <dependency>
  92. <groupId>org.springframework</groupId>
  93. <artifactId>spring-jdbc</artifactId>
  94. <version>4.0.9.RELEASE</version>
  95. </dependency>
  96. <dependency>
  97. <groupId>org.springframework</groupId>
  98. <artifactId>spring-test</artifactId>
  99. <version>4.0.9.RELEASE</version>
  100. </dependency>
  101. <dependency>
  102. <groupId>org.codehaus.jackson</groupId>
  103. <artifactId>jackson-core-asl</artifactId>
  104. <version>1.9.11</version>
  105. </dependency>
  106. <dependency>
  107. <groupId>org.codehaus.jackson</groupId>
  108. <artifactId>jackson-mapper-asl</artifactId>
  109. <version>1.9.11</version>
  110. </dependency>
  111. </dependencies>
  112. <build>
  113. <finalName>webFormTest</finalName>
  114. </build>
  115. </project>

2.web项目基本配置文件web.xml:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  4. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  5. id="WebApp_ID" version="2.5">
  6. <filter>
  7. <description>字符集过滤器</description>
  8. <filter-name>encodingFilter</filter-name>
  9. <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  10. <init-param>
  11. <description>字符集编码</description>
  12. <param-name>encoding</param-name>
  13. <param-value>UTF-8</param-value>
  14. </init-param>
  15. </filter>
  16. <filter-mapping>
  17. <filter-name>encodingFilter</filter-name>
  18. <url-pattern>/*</url-pattern>
  19. </filter-mapping>
  20. <servlet>
  21. <servlet-name>springMVC</servlet-name>
  22. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  23. <init-param>
  24. <param-name>contextConfigLocation</param-name>
  25. <param-value>classpath:spring.xml</param-value>
  26. </init-param>
  27. </servlet>
  28. <servlet-mapping>
  29. <servlet-name>springMVC</servlet-name>
  30. <url-pattern>*.do</url-pattern>
  31. </servlet-mapping>
  32. <welcome-file-list>
  33. <welcome-file>index.html</welcome-file>
  34. <welcome-file>index.htm</welcome-file>
  35. <welcome-file>index.jsp</welcome-file>
  36. <welcome-file>default.html</welcome-file>
  37. <welcome-file>default.htm</welcome-file>
  38. <welcome-file>default.jsp</welcome-file>
  39. </welcome-file-list>
  40. </web-app>

3.sping相关配置文件:spring.xml:

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <beans xmlns="http://www.springframework.org/schema/beans"
    3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    4. xmlns:context="http://www.springframework.org/schema/context"
    5. xmlns:mvc="http://www.springframework.org/schema/mvc"
    6. xsi:schemaLocation="
    7. http://www.springframework.org/schema/beans
    8. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    9. http://www.springframework.org/schema/context
    10. http://www.springframework.org/schema/context/spring-context-3.0.xsd
    11. http://www.springframework.org/schema/mvc
    12. http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    13. <context:annotation-config />
    14. <mvc:annotation-driven />
    15. <context:component-scan base-package="formControllers" />
    16. <context:component-scan base-package="servicesImp" />
    17. <!--
    18. <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
    19. <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
    20. <property name="url" value="jdbc:mysql://192.168.0.201:3306/formtest?useUnicode=true&characterEncoding=utf8" ></property>
    21. <property name="username" value="root" ></property>
    22. <property name="password" value="123456" ></property>
    23. </bean>
    24. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    25. <property name="dataSource" ref="dataSource"></property>
    26. </bean>
    27. -->
    28. <!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
    29. <bean id="mappingJacksonHttpMessageConverter"
    30. class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
    31. <property name="supportedMediaTypes">
    32. <list>
    33. <value>text/html;charset=utf-8</value>
    34. </list>
    35. </property>
    36. </bean>
    37. <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
    38. <bean
    39. class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    40. <property name="messageConverters">
    41. <list>
    42. <ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->
    43. </list>
    44. </property>
    45. </bean>
    46. </beans>
上一篇:AlloyTouch Button插件-不再愁click延迟和点击态


下一篇:裁剪要素出现错误 :HRESULT:0x80040239