新聞中心
要在JSP頁(yè)面中顯示JBPM流程圖需要先下載jbpm-starters-kit-3.1.x工具包。在包中有.java文件,

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)公司!專(zhuān)注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、重慶小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶(hù)創(chuàng)新互聯(lián)還提供了河南免費(fèi)建站歡迎大家使用!
\jbpm.3\src\java.webapp\org\jbpm\webapp\tag\ProcessImageTag.java與他的\WEB-INF\jbpm.tld,還有文件
\jbpm.3\src\java.webapp\org\jbpm\webapp\servlet\ ProcessImageServlet.java,在JBPM的例子里,這三個(gè)文件共同完成JBPM流程圖的顯示。
要使兩個(gè)文件發(fā)生作用,必須得在web.xml里配置,配置方法:
ProcessImageServlet org.jbpm.webapp.servlet.ProcessImageServlet ProcessImageServlet /processimage
在頁(yè)面中使用:
在實(shí)際環(huán)境中可能會(huì)出現(xiàn)的問(wèn)題與必要的修改
問(wèn)題一
如果你是用spring整合的jbpm,那么在兩個(gè)類(lèi)里的取JbpmContext方法會(huì)出錯(cuò)。
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext(); //這個(gè)是會(huì)出問(wèn)題的。
修改:
1.ProcessImageTag.java的private void initialize()方法里。
- WebApplicationContext wac = WebApplicationContextUtils.
getRequiredWebApplicationContext(pageContext.getServletContext());- JbpmTemplate jbpmTemplate = (JbpmTemplate) wac.getBean("jbpmTemplate");
- jbpmTemplate.execute(new JbpmCallback() {
- public Object doInJbpm(JbpmContext context) {
- if (taskInstanceId > 0) {
- TaskInstance taskInstance = context.getTaskMgmtSession().loadTaskInstance(taskInstanceId);
- currentToken = taskInstance.getToken();
- }
- else
- {
- if (tokenInstanceId > 0)
- currentToken = context.getGraphSession().loadToken(tokenInstanceId);
- }
- return null;
- }
- });
public class ProcessImageServlet extends HttpServlet {- private static final long serialVersionUID = 1L;
- private ProcessDefinition processDefinition;
- private byte[] bytes;
- protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {- final long processDefinitionId = Long.parseLong( request.getParameter( "definitionId" ) );
- WebApplicationContext wac = WebApplicationContextUtils.
getRequiredWebApplicationContext(request.getSession().getServletContext());- JbpmTemplate jbpmTemplate = (JbpmTemplate) wac.getBean("jbpmTemplate");
- jbpmTemplate.execute(new JbpmCallback() {
- public Object doInJbpm(JbpmContext context) {
- processDefinition = context.getGraphSession().loadProcessDefinition(processDefinitionId);
- bytes = processDefinition.getFileDefinition().getBytes("processimage.jpg");
- return null;
- }
- });
- OutputStream out = response.getOutputStream();
- out.write(bytes);
- out.flush();
- }
- }
問(wèn)題二
如果你的流程是用中文字符,且數(shù)據(jù)庫(kù)字符集為utf-8,再數(shù)據(jù)庫(kù)中為正確的utf-8內(nèi)容,也可能會(huì)亂碼錯(cuò)誤。 如:我的數(shù)據(jù)庫(kù)里的gpd.xml
出錯(cuò)的類(lèi):ProcessImageTag.java
出錯(cuò)行:result[0] = Integer.valueOf(node.attribute("x").getValue());
如果此地為nullpoint錯(cuò)誤,是因?yàn)樯舷挛牡腅lement root中的字符為亂碼。
修改:
原代碼:Element rootDiagramElement = DocumentHelper.parseText(new String(gpdBytes)).getRootElement();
修改后:Element rootDiagramElement = DocumentHelper.parseText(new String(gpdBytes, "utf-8")).getRootElement();
說(shuō)明:有個(gè)地方要注意,
原代碼:background-image:url(" + imageLink + ");
修改后:background-image:url(" + ((HttpServletRequest) pageContext.getRequest()).getContextPath() + "/" + imageLink + ");
至此成功顯示JBPM流程圖。
本文標(biāo)題:在JSP頁(yè)面中顯示JBPM流程圖
URL網(wǎng)址:http://www.5511xx.com/article/djchijp.html


咨詢(xún)
建站咨詢(xún)
