package com.tenwa.customer.handler.tell; import jbo.app.tenwa.customer.CUSTOMER_ADDRESS; import jbo.app.tenwa.customer.CUSTOMER_TEL; 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 CustomerTelHandler extends CommonHandler{ @Override//新增初始化 protected void initDisplayForAdd(BizObject bo) throws Exception { String customerId=this.asPage.getAttribute("customerId").toString(); bo.setAttributeValue("customerid",customerId); bo.setAttributeValue("isnew","yes"); super.initDisplayForAdd(bo); } @Override protected void beforeInsert(JBOTransaction tx, BizObject bo)throws Exception { //获取当前客户ID String customerId=this.asPage.getAttribute("customerId").toString(); String teltype=bo.getAttribute("teltype").toString(); BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_TEL .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 teltype=:teltype"); boq.setParameter("customerid", customerId).setParameter("teltype",teltype); boq.executeUpdate(); } super.beforeInsert(tx, bo); } }