⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modefyproductaction.java

📁 这是本人曾经在公司里用的,内部开发框架,基于struts+hibernate今天分享给大家
💻 JAVA
字号:
/**
 * 
 */
package cn.bway.foreigntrade.reperstory.product.action;

import java.sql.Connection;
import java.sql.SQLException;
import javax.servlet.http.*;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.*;
import org.hibernate.Session;
import org.hibernate.Transaction;
import cn.bway.common.BwayException;
import cn.bway.common.BwayHibernateException;
import cn.bway.common.WebConstant;
import cn.bway.common.action.BaseAction;
import cn.bway.common.dao.HibernateSessionFactory;
import cn.bway.foreigntrade.operation.productmanage.form.ProductmanageForm;
import cn.bway.foreigntrade.operation.productmanage.model.Productmanage;
import cn.bway.foreigntrade.reperstory.product.form.ProductForm;
import cn.bway.foreigntrade.reperstory.product.impl.ProductManagerFactory;
import cn.bway.foreigntrade.reperstory.product.model.Product;
import cn.bway.foreigntrade.repertory.storymanagement.impl.StorymanagementManagerFactory;
import cn.bway.foreigntrade.repertory.storymanagement.model.Storymanagement;



/**
 * @author Kson
 *
 */
public class ModefyProductAction extends BaseAction {

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws BwayException 
	 * @throws SQLException 
	 * @throws Exception
	 */
	public ActionForward execute(ActionMapping mapping,
				ActionForm form,HttpServletRequest request,	HttpServletResponse response)
				throws BwayHibernateException, BwayException, SQLException {		
		ProductForm pForm = (ProductForm) form;
		ActionErrors errors = new ActionErrors();
		Session sess = null;
		Transaction tx = null;
		String returnStr = null;
		Connection conn = null;
		String act=request.getParameter("act");
		String id = request.getParameter("id");
		try {//閺囧瓨鏌奝ersonal鐞涳拷
			request.setCharacterEncoding("utf-8");
			if("modefy".equals(act)){//閺屻儳婀呴幙宥勭稊
				Product per=(Product) ProductManagerFactory.getProductManager().getProduct(id);
				request.setAttribute("ModilfyProduct", per);
				returnStr ="view";
			}else{
				Product exp=(Product) ProductManagerFactory.getProductManager().getProduct(request.getParameter("id"));	
				exp.setCodes(pForm.getCodes());
				exp.setNames(pForm.getNames());
				exp.setPrice(pForm.getPrice());					
				exp.setSpec(pForm.getSpec());
				exp.setCraftwork(pForm.getCraftwork());					
				exp.setColor(pForm.getColor());
				exp.setStuff(pForm.getStuff());
				exp.setProvide(pForm.getProvide());
				exp.setProductionperiod(pForm.getProductionperiod());
				exp.setQc(pForm.getQc());
				exp.setTypes(pForm.getTypes());
				exp.setNumbers(pForm.getNumbers());
				ProductManagerFactory.getProductManager().modfilyProduct(exp);
				returnStr=WebConstant.FORWARD_INITPAGE;
			}
		} catch (Exception e) {//瀵倸鐖舵径鍕倞閿涘苯鍙忕仦锟芥潪顒佸床閼风牣rror.jsp
			errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("edu.system.excption", e.getMessage()));
			this.saveErrors(request, errors);
			tx.rollback();
			e.printStackTrace();
		} finally {
			try {
				if (null != conn) {
					conn.close();
				}
			} catch (Exception ex) {
				ex.printStackTrace();
			}
			HibernateSessionFactory.closeSession();
		}
		return mapping.findForward(returnStr);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -