1. Create a Processdefinitionaction.java
Package Cn.itcast.oa.view.action;import Java.io.file;import Java.io.fileinputstream;import java.io.InputStream; Import Java.util.list;import Java.util.zip.zipinputstream;import Org.jbpm.api.processdefinition;import Org.springframework.context.annotation.scope;import Org.springframework.stereotype.controller;import Cn.itcast.oa.service.processdefinitionservice;import Com.opensymphony.xwork2.ActionContext; @Controller @scope (" Prototype ") public class Processdefinitionaction extends Baseaction{private String key; Private File upload; Upload private String id;private inputstream InputStream; Download the/** list */public String list () throws Exception {list<processdefinition> processdefinitionlist= Processdefinitionservice.findalllatestversions (); Actioncontext.getcontext (). Put ("Processdefinitionlist", processdefinitionlist); return "List";} /** deployment Process Definition page */public String addui () throws Exception {return "Addui";} /** deployment Process Definition */public String Add () throws Exception {Zipinputstream zipinputstream=new zipinPutstream (new FileInputStream (upload));p Rocessdefinitionservice.deploy (zipinputstream); return "ToList";} /** Delete process definition */public String Delete () throws Exception {Processdefinitionservice.deletebykey (key); return "ToList";} /** list */public String downloadprocessinmage () throws Exception {inputstream= Processdefinitionservice.getprocessimageresourceasstream (ID); return "Downloadprocessinmage";} ----------------------public InputStream getInputStream () {return inputstream;} public void Setinputstream (InputStream inputstream) {this.inputstream = InputStream;} Public String GetKey () {return key;} Public File Getupload () {return upload;} public void Setupload (File upload) {this.upload = upload;} public void Setkey (String key) {This.key = key;} Public String GetId () {return ID;} public void SetId (String id) {this.id = id;}}
2. How to implement the corresponding service layer
3. Configuring the Strutsxml File
<!--approval Flow: Approval process management--><action name= "processdefinitionaction_*" class= "processdefinitionaction" method= "{1}" ><result name= "list" >/web-inf/jsp/processdefinitionaction/list.jsp</result><result name= "AddUI ">/web-inf/jsp/processdefinitionaction/addui.jsp</result><result name=" toList "type=" RedirectAction " >processDefinitionAction_list</result><!--Download Dedicated results configuration--><result name= "Downloadprocessimage" type = "Stream" > <param name= "contentType" >image/png</param> <param name= "InputName" >inputstream </param></result></action>
4. Add the appropriate page to
ssh2+jbpm4.4 Project Approval Flow: The thinking of approval process management