package com.tenwa.customer.handler.address; import jbo.app.tenwa.customer.CUSTOMER_ADDRESS; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.BizObjectQuery; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.awe.dw.handler.impl.CommonHandler; public class CustomerAddressHandler extends CommonHandler{ @Override protected void initDisplayForAdd(BizObject bo) throws Exception { //获取当前客户ID String customer_id=this.asPage.getAttribute("customer_id").toString(); //初始化状态和客户ID bo.setAttributeValue("customerid", customer_id); super.initDisplayForAdd(bo); } @Override protected void beforeInsert(JBOTransaction tx, BizObject bo)throws Exception { //获取当前客户ID String customer_id=this.asPage.getAttribute("customer_id").toString(); String addtype=bo.getAttribute("addtype").toString(); BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ADDRESS.CLASS_NAME); tx.join(bom); //判断当前新增联系地址是否最新,是则把此类型其它联系地址都设为非最新 if(bo.getAttribute("isnew").toString().equals("yes")){ BizObjectQuery boq = bom.createQuery("update O set isnew = 'no' where customerid=:customerid and addtype=:addtype"); boq.setParameter("customerid", customer_id).setParameter("addtype",addtype); boq.executeUpdate(); } super.beforeInsert(tx, bo); } }