日期:2014-05-16 浏览次数:20351 次
<bean id="attachmentDao" class="com.ibm.process.persistence.dao.ProcessAttachmentDAO"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean>
/* * 创建日期: 2006-4-29 * Version: 1.0 */ package com.ibm.process.persistence.dao; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import com.ibm.process.persistence.pojo.ProcessAttachment; /** * * TJMCC EIP II Copyright:IBM BCS * * @author fengfei * */ public class ProcessAttachmentDAO extends HibernateDaoSupport { //查询 public ProcessAttachment query(Integer fileId) { java.util.List list = this.getHibernateTemplate().find( "from ProcessAttachment a where a.fileId=?", fileId); if (list == null || list.size() == 0) return null; return (ProcessAttachment) list.get(0); } //增加保存 public void add(ProcessAttachment attachment) { this.getHibernateTemplate().save(attachment); } public void delete(ProcessAttachment attachment) { this.getHibernateTemplate().delete(attachment); } //修改 public void modify(ProcessAttachment attachment) { this.getHibernateTemplate().update(attachment); } //查询多个 public List queryAttachmentList(Integer processId) { List list = null; if (processId != null && !"".equals(processId)) { list = this.getHibernateTemplate() .find("from ProcessAttachment pc where pc.processId=?", processId); } if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { ProcessAttachment temp = (ProcessAttachment) list.get(i); temp.setTempFileName(temp.getFileName().substring(14, temp.getFileName().length())); } } return list; } public List ListProcessAttachment(Integer processId) { List list = null; if (processId != null && !processId.equals("")) { list = this.getHibernateTemplate() .find("from ProcessAttachment pc where pc.processId=?", processId); } if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { ProcessAttachment temp = (ProcessAttachment) list.get(i); temp.setTempFileName(temp.getFileName().substring(14, temp.getFileName().length())); } } return list; } //删除 public void removeByFormId(Integer processId) { List list = this.queryAttachmentList(processId); if (list != null) { for (int i = 0; i < list.size(); i++) { delete((ProcessAttachment) list.get(i)); } } } }
<bean id="attachmentHandle" class="com.ibm.process.web.fileupload.ProcessAttachmentHandler"> <property name="dao" ref="attachmentDao"/> <property name="upload" ref="upload"/> </bean>
<bean name="/Apply" parent="actionTemplate"> <property name="target"> <bean class="Action"> <property name="handle" ref="attachmentHandle"/> </bean> </property> </bean>
import com.ibm.process.web.fileupload.ProcessAttachmentHandler; private ProcessAttachmentHandler handle; /** * @return Returns the handle. */ public ProcessAttachmentHandler getHandle() { return handle; } /** * @param handle * The handle to set. */ public void setHandle(ProcessAttachme