BillListPanel中获得选中的行

获取表格选中行数据
本文介绍了通过不同方法从面板的头部表格中获取选中行数据的具体实现方式。包括使用 getBillHeadTable 和 getBillHeadModel 的 getSelectRow 方法直接获取选中行,以及利用 getHeadBillModel 的 getBodyValueRowVO 方法来获取指定类的对象。

int row = getBillListPanel().getBillHeadTable().getSelectRow();  
  

//作用相同  
getBillListPanel().getBillHeadModel().getSelectRowVO(row,vo.class);  
  
getBillListPanel().getHeadBillModel().getBodyValueRowVO(row, vo.class.getName());  

 
/* */ package nc.ui.fdcprcm.businesscenter.action; /* */ /* */ import java.awt.Container; /* */ import java.awt.event.ActionEvent; /* */ import nc.bs.framework.common.NCLocator; /* */ import nc.itf.fdcpr.bdcenter.IBdCenterMaintain; /* */ import nc.ui.fdcpr.uipub.view.JZFDCShowUpableBillListView; /* */ import nc.ui.fdcprcu.customer.ref.BDCustomerRefModel; /* */ import nc.ui.pub.beans.MessageDialog; /* */ import nc.ui.pub.beans.UIRefPane; /* */ import nc.ui.pub.bill.BillListPanel; /* */ import nc.ui.pub.bill.BillTabbedPane; /* */ import nc.ui.pubapp.util.ListPanelValueUtils; /* */ import nc.ui.uif2.NCAction; /* */ import nc.ui.uif2.model.AbstractAppModel; /* */ import nc.ui.uif2.model.BillManageModel; /* */ import nc.vo.fdcprbd.bdcenter.AggBdCenterHouseVO; /* */ import nc.vo.fdcprbd.bdcenter.BdCenterHouseOwnerVO; /* */ import nc.vo.fdcprbd.bdcenter.BdCenterHouseVO; /* */ import nc.vo.fdcprbd.enums.HistoryStatusEnum; /* */ import nc.vo.fdcprcu.customer.BdCustomerVO; /* */ import nc.vo.pub.BusinessException; /* */ import nc.vo.pub.ISuperVO; /* */ import nc.vo.pub.ValueObject; /* */ import nc.vo.pub.lang.UFBoolean; /* */ import nc.vo.pubapp.pattern.model.entity.bill.IBill; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class ChangeHouseOwnerAction /* */ extends NCAction /* */ { /* */ private static final long serialVersionUID = -4011201685479361703L; /* 48 */ private String btnCode = "changeHouseOwnerAction"; /* 49 */ private String btnName = "业主变更"; /* */ private AbstractAppModel model; /* */ private JZFDCShowUpableBillListView listView; /* */ /* */ public void setModel(AbstractAppModel model) { /* 54 */ this.model = model; /* 55 */ model.addAppEventListener(this); /* */ } /* */ /* */ public AbstractAppModel getModel() { /* 59 */ return model; /* */ } /* */ /* */ public JZFDCShowUpableBillListView getListView() { /* 63 */ return listView; /* */ } /* */ /* */ public void setListView(JZFDCShowUpableBillListView listView) { /* 67 */ this.listView = listView; /* */ } /* */ /* */ /* */ /* */ public ChangeHouseOwnerAction() /* */ { /* 74 */ setCode(btnCode); /* 75 */ setBtnName(btnName); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void doAction(ActionEvent e) /* */ throws Exception /* */ { /* 85 */ checkSelectedData(); /* */ /* */ /* 88 */ String[] newOwner_pks = openRefDialog(listView); /* 89 */ if ((newOwner_pks == null) || (newOwner_pks.length == 0)) { /* 90 */ return; /* */ } /* */ /* */ /* 94 */ AggBdCenterHouseVO aggvo = getSelectedData(); /* */ /* */ /* 97 */ replaceOwner(aggvo, newOwner_pks); /* */ /* */ /* 100 */ listView.getBillListPanel().getBodyTabbedPane().setSelectedIndex(0); /* */ } /* */ /* */ /* */ /* */ /* */ protected boolean isActionEnable() /* */ { /* 108 */ AggBdCenterHouseVO aggvo = (AggBdCenterHouseVO)listView.getModel().getSelectedData(); /* */ /* 110 */ if (aggvo == null) /* 111 */ return false; /* 112 */ BdCenterHouseVO headvo = (BdCenterHouseVO)aggvo.getParent(); /* 113 */ if (headvo == null) /* 114 */ return false; /* 115 */ if (headvo.getPk_house() == null) /* 116 */ return false; /* 117 */ return true; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private void checkSelectedData() /* */ throws BusinessException /* */ { /* 130 */ if (!isActionEnable()) { /* 131 */ throw new BusinessException("需要选中业主"); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ private AggBdCenterHouseVO getSelectedData() /* */ throws BusinessException /* */ { /* 143 */ AggBdCenterHouseVO aggvo = (AggBdCenterHouseVO)listView.getModel().getSelectedData(); /* */ /* 145 */ return aggvo; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private String[] openRefDialog(Container parent) /* */ throws BusinessException /* */ { /* 158 */ ListPanelValueUtils util = new ListPanelValueUtils(getListView().getBillListPanel()); /* 159 */ String pk_org = util.getHeadStringValueAt(listView.getModel().getSelectedRow(), "pk_org"); /* */ /* 161 */ BDCustomerRefModel refModel = new BDCustomerRefModel(null); /* 162 */ refModel.setPk_org(pk_org); /* */ /* */ /* 165 */ UIRefPane refpanel = new UIRefPane(); /* 166 */ refpanel.setRefModel(refModel); /* 167 */ refpanel.setMultiSelectedEnabled(true); /* 168 */ refpanel.showModel(); /* */ /* 170 */ if (refpanel.getReturnButtonCode() != 1) { /* 171 */ return null; /* */ } /* */ /* 174 */ ValueObject[] vos = refpanel.getVOs(); /* 175 */ String[] pks = new String[vos.length]; /* 176 */ for (int i = 0; i < vos.length; i++) { /* 177 */ BdCustomerVO vo = (BdCustomerVO)vos[i]; /* 178 */ pks[i] = vo.getPk_customer(); /* */ } /* 180 */ return pks; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private void replaceOwner(AggBdCenterHouseVO selectedAggvo, String[] newOwner_pks) /* */ { /* 195 */ BdCenterHouseVO headvo = (BdCenterHouseVO)selectedAggvo.getParent(); /* 196 */ if ((newOwner_pks.length > 1) && ((headvo.getBjoint() == null) || (!headvo.getBjoint().booleanValue()))) { /* 197 */ headvo.setBjoint(new UFBoolean(true)); /* 198 */ headvo.setStatus(1); /* 199 */ } else if ((newOwner_pks.length == 1) && (headvo.getBjoint().booleanValue())) { /* 200 */ headvo.setBjoint(new UFBoolean(false)); /* 201 */ headvo.setStatus(1); /* */ } /* */ /* */ /* 205 */ ISuperVO[] oldOwners = selectedAggvo.getChildren(BdCenterHouseOwnerVO.class); /* 206 */ for (ISuperVO iSuperVO : oldOwners) { /* 207 */ BdCenterHouseOwnerVO oldOwner = (BdCenterHouseOwnerVO)iSuperVO; /* 208 */ String customerStatus = oldOwner.getVcustomerstatus(); /* */ /* 210 */ if (customerStatus.equals(HistoryStatusEnum.NOW.toStringValue())) { /* 211 */ oldOwner.setVcustomerstatus(HistoryStatusEnum.HISTORY.toStringValue()); /* 212 */ oldOwner.setStatus(1); /* */ } /* */ } /* */ /* */ /* 217 */ int newLen = newOwner_pks.length + oldOwners.length; /* 218 */ BdCenterHouseOwnerVO[] newOwners = new BdCenterHouseOwnerVO[newLen]; /* 219 */ for (int i = 0; i < newOwner_pks.length; i++) { /* 220 */ BdCenterHouseOwnerVO newOwnerVO = new BdCenterHouseOwnerVO(); /* 221 */ newOwnerVO.setPk_center(headvo.getPk_center()); /* 222 */ newOwnerVO.setPk_customer(newOwner_pks[i]); /* 223 */ newOwnerVO.setVcustomerstatus(HistoryStatusEnum.NOW.toStringValue()); /* 224 */ newOwnerVO.setStatus(2); /* 225 */ newOwners[i] = newOwnerVO; /* */ } /* */ /* */ /* 229 */ System.arraycopy(oldOwners, 0, newOwners, newOwner_pks.length, oldOwners.length); /* 230 */ selectedAggvo.setChildrenVO(newOwners); /* */ /* */ /* 233 */ IBdCenterMaintain maintain = (IBdCenterMaintain)NCLocator.getInstance().lookup(IBdCenterMaintain.class); /* */ try { /* 235 */ IBill[] updated = maintain.update(new IBill[] { selectedAggvo }); /* 236 */ MessageDialog.showHintDlg(listView, "成功提示", "更换业主成功"); /* 237 */ listView.getModel().directlyUpdate(updated[0]); /* */ } catch (BusinessException e) { /* 239 */ MessageDialog.showErrorDlg(listView, "错误提示", "更换业主失败:" + e.getMessage()); /* */ } /* */ } /* */ }
最新发布
10-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值