本设计后台采用ssh,前台采用Extjs4 ,因为项目需要图片且图片显示采用字节流InputStream。
后台代码:
@Action(value = "read",results = { @Result(name =
"success", type = "stream") })
public String loadByDeployment() throws
Exception {
ProcessDefinition processDefinition =
repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
String resourceName = "";
if
(resourceType.equals("image")) {
resourceName =
processDefinition.getDiagramResourceName();
} else if
(resourceType.equals("xml")) {
resourceName =
processDefinition.getResourceName();
}
InputStream resourceAsStream =
repositoryService.getResourceAsStream(processDefinition.getDeploymentId(),
resourceName);
this.setInputStream(resourceAsStream);
return
SUCCESS;
}
使用的是Struts注解方式,用stream类型的Result实现Ajax,对应的是InputStream字节流形式。
前台代码:
var changingImage = Ext.create(‘Ext.Img‘, {
src: approot +
‘/ActivitiAct/read.action?resourceType=image&processDefinitionId=‘+record.data.id+‘‘,
renderTo: Ext.getBody()
});
Ext.create(‘Ext.window.Window‘,
{
title: ‘流程图‘,
height:480,
closable :true,
autoScroll:true,
layout:
‘fit‘,
items:
changingImage
}).show();
效果图: