Skip to content

Commit

Permalink
添加了动态form演示的雏形
Browse files Browse the repository at this point in the history
  • Loading branch information
henryyan committed Jul 17, 2012
1 parent 073a50c commit 7f773b8
Show file tree
Hide file tree
Showing 16 changed files with 254 additions and 42 deletions.
41 changes: 33 additions & 8 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
4 changes: 2 additions & 2 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
Expand Down
3 changes: 2 additions & 1 deletion .settings/org.eclipse.wst.common.component
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<property name="context-root" value="kft-activiti-demo"/>
<property name="java-output-path" value="/kft-activiti-demo/target/classes"/>
</wb-module>
Expand Down
20 changes: 0 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.1</version>
</dependency>
<!-- GENERAL UTILS end -->

Expand Down Expand Up @@ -269,25 +268,6 @@

<build>
<plugins>
<!-- 增加functional test的Source目录 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-functional-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/functional</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- test插件, 设置內存/ClassLoader -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public ProcessDefinition findProcessDefinition(String processDefinitionId) {
*/
public void deployFromClasspath(String... processKey) throws Exception {
ResourceLoader resourceLoader = new DefaultResourceLoader();
String[] processKeys = { "leave" };
String[] processKeys = { "leave", "leave-dynamic-from" };
for (String loopProcessKey : processKeys) {

/*
Expand Down Expand Up @@ -110,7 +110,7 @@ public void deployFromClasspath(String... processKey) throws Exception {
* @throws IOException 找不到zip文件时
*/
private void deploySingleProcess(ResourceLoader resourceLoader, String processKey) throws IOException {
String classpathResourceUrl = "classpath:/diagrams/" + processKey + "/" + processKey + ".zip";
String classpathResourceUrl = "classpath:/deployments/" + processKey + ".zip";
logger.debug("read workflow from: {}", classpathResourceUrl);
Resource resource = resourceLoader.getResource(classpathResourceUrl);
InputStream inputStream = resource.getInputStream();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package me.kafeitu.demo.activiti.web.form.dynamic;

import java.util.ArrayList;
import java.util.List;

import org.activiti.engine.FormService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.form.StartFormData;
import org.activiti.engine.impl.form.StartFormDataImpl;
import org.activiti.engine.repository.ProcessDefinition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
* 动态FormController
*
* @author HenryYan
*/
@Controller
@RequestMapping(value = "/form/dynamic")
public class DynamicFormController {

@Autowired
private RepositoryService repositoryService;

@Autowired
private FormService formService;

/**
* 动态form流程列表
* @param model
* @return
*/
@RequestMapping(value = { "list", "" })
public ModelAndView processDefinitionList(Model model) {
ModelAndView mav = new ModelAndView("/form/dynamic/dynamic-form-process-list");
List<ProcessDefinition> newResult = new ArrayList<ProcessDefinition>();
List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().list();

/*
* 只读取包含dynamic的流程
*/
for (ProcessDefinition processDefinition : list) {
if (processDefinition.getKey().indexOf("dynamic") != -1) {
newResult.add(processDefinition);
}
}
mav.addObject("processes", newResult);
return mav;
}

/**
* 读取启动流程的表单字段
*/
@RequestMapping(value = "get-start-form-field/{processDefinitionId}")
@ResponseBody
public StartFormData findFieldOfForm(@PathVariable("processDefinitionId") String processDefinitionId) throws Exception {
StartFormDataImpl startFormData = (StartFormDataImpl) formService.getStartFormData(processDefinitionId);
startFormData.setProcessDefinition(null);
return startFormData;
}

}
Binary file modified src/main/resources/deployments/leave-dynamic-from.zip
Binary file not shown.
Binary file modified src/main/resources/deployments/leave.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@
<omgdi:waypoint x="270" y="127"></omgdi:waypoint>
<omgdi:waypoint x="270" y="190"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="13" width="100" x="10" y="0"></omgdc:Bounds>
<omgdc:Bounds height="11" width="100" x="10" y="0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="290" y="107"></omgdi:waypoint>
<omgdi:waypoint x="358" y="107"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="13" width="100" x="-24" y="-17"></omgdc:Bounds>
<omgdc:Bounds height="11" width="100" x="-24" y="-17"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
Expand All @@ -106,7 +106,7 @@
<omgdi:waypoint x="535" y="107"></omgdi:waypoint>
<omgdi:waypoint x="590" y="107"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="13" width="100" x="-27" y="-17"></omgdc:Bounds>
<omgdc:Bounds height="11" width="100" x="-27" y="-17"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
Expand All @@ -118,15 +118,15 @@
<omgdi:waypoint x="514" y="217"></omgdi:waypoint>
<omgdi:waypoint x="323" y="217"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="13" width="100" x="10" y="0"></omgdc:Bounds>
<omgdc:Bounds height="11" width="100" x="10" y="0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
<omgdi:waypoint x="250" y="300"></omgdi:waypoint>
<omgdi:waypoint x="142" y="299"></omgdi:waypoint>
<omgdi:waypoint x="142" y="135"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="13" width="100" x="10" y="0"></omgdc:Bounds>
<omgdc:Bounds height="11" width="100" x="10" y="0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
Expand All @@ -137,7 +137,7 @@
<omgdi:waypoint x="290" y="300"></omgdi:waypoint>
<omgdi:waypoint x="625" y="300"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="13" width="100" x="10" y="0"></omgdc:Bounds>
<omgdc:Bounds height="11" width="100" x="10" y="0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<head>
<%@ include file="/common/global.jsp"%>
<title>动态Form流程列表</title>
<%@ include file="/common/meta.jsp" %>
<%@ include file="/common/include-base-styles.jsp" %>
<%@ include file="/common/include-jquery-ui-theme.jsp" %>
<link href="${ctx }/js/common/plugins/jui/extends/timepicker/jquery-ui-timepicker-addon.css" type="text/css" rel="stylesheet" />

<script src="${ctx }/js/common/jquery.js" type="text/javascript"></script>
<script src="${ctx }/js/common/plugins/jui/jquery-ui.min.js" type="text/javascript"></script>
<script src="${ctx }/js/common/plugins/jui/extends/timepicker/jquery-ui-timepicker-addon.js" type="text/javascript"></script>
<script src="${ctx }/js/common/plugins/jui/extends/i18n/jquery-ui-date_time-picker-zh-CN.js" type="text/javascript"></script>
<script src="${ctx }/js/common/common.js" type="text/javascript"></script>
<script src="${ctx }/js/module/form/dynamic/process.js?v=${timeInMillis}" type="text/javascript"></script>
</head>

<body>
<table width="100%" class="need-border">
<thead>
<tr>
<th>ID</th>
<th>DID</th>
<th>名称</th>
<th>KEY</th>
<th>版本号</th>
<th>XML</th>
<th>图片</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<c:forEach items="${processes }" var="process">
<tr>
<td class='process-id'>${process.id }</td>
<td>${process.deploymentId }</td>
<td class='process-name'>${process.name }</td>
<td>${process.key }</td>
<td>${process.version }</td>
<td><a target="_blank" href='${ctx }/workflow/resource/deployment?deploymentId=${process.deploymentId}&resourceName=${process.resourceName }'>${process.resourceName }</a></td>
<td><a target="_blank" href='${ctx }/workflow/resource/deployment?deploymentId=${process.deploymentId}&resourceName=${process.diagramResourceName }'>${process.diagramResourceName }</a></td>
<td><a class="startup-process">启动</a></td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
8 changes: 7 additions & 1 deletion src/main/webapp/WEB-INF/views/main/menu.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
<ul id="css3menu">
<li class="topfirst"><a rel="main/welcome">首页</a></li>
<li>
<a rel="#">考勤模块</a>
<a rel="#">请假(自定义表单)</a>
<ul>
<li><a rel="oa/leave/apply">请假申请</a></li>
<li><a rel="oa/leave/list/task">请假办理</a></li>
<li><a rel="oa/leave/list/running">运行中流程</a></li>
<li><a rel="oa/leave/list/finished">已结束流程</a></li>
</ul>
</li>
<li>
<a rel="#">动态表单</a>
<ul>
<li><a rel="form/dynamic/list">流程列表</a></li>
</ul>
</li>
<li>
<a rel="#">工作流</a>
<ul>
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<session-timeout>20</session-timeout>
</session-config>

<!-- 出错页面定义 -->
<!-- 出错页面定义
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/WEB-INF/views/error/500.jsp</location>
Expand All @@ -84,5 +84,5 @@
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/views/error/404.jsp</location>
</error-page>
</error-page> -->
</web-app>
1 change: 1 addition & 0 deletions src/main/webapp/common/global.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ String themeVersion = "1.8.16";
session.setAttribute("themeName", defaultTheme);
session.setAttribute("themeVersion", themeVersion);
pageContext.setAttribute("timeInMillis", System.currentTimeMillis());
%>
<script type="text/javascript">
var ctx = '<%=request.getContextPath() %>';
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ td.label {
-khtml-border-bottom-right-radius: 12px;
border-bottom-right-radius: 12px;
}

/* 自动完成的loading图片 */
.ui-loading { background: url('../images/ajax/loading.gif') right center no-repeat; padding-left: 18px;}
Loading

0 comments on commit 7f773b8

Please sign in to comment.