1.功能描述:如图所示,压力因子是参照,新增一行时压力因子不能重复
2.该功能用表体编辑后事件,代码如下:
@Override
public void handleAppEvent(CardBodyAfterEditEvent e) {
try{
if (e.getKey().equals("is_nor_para")) {
setCellEditable(e);
}else if (e.getKey().equals("pk_coa")){
UIRefPane pk_coa = (UIRefPane)e.getBillCardPanel().getBodyItem("pk_coa").getComponent();
String[] refPKs = pk_coa.getRefPKs();
e.getBillCardPanel().setBodyValueAt(getPkStrs(refPKs), e.getRow(), "pkcoa_show");
e.getBillCardPanel().setBodyValueAt(getPkStrs(refPKs), e.getRow(), "pk_coa");
}else if (e.getKey().equals("pk_sfpara_set")){
judgeRepeatedData(e);
}
}catch(Exception e1){
getExceptionHandler().handlerExeption(e1);
}
}
/**
* 编辑时判断子表数据是否重复
* @param e
*/
private void judgeRepeatedData(CardBodyAfterEditEvent e) {
String edittingRowValue = e.getValue().toString();
int edittingRow = e.getRow();
int rowCount = e.getBillCardPanel().getRowCount();
if(StringUtils.isNotBlank(edittingRowValue)){
for(int i = 0; i < rowCount; i++){
if(edittingRow == i){
break;
}
String otherRowValue = e.getBillCardPanel().getBodyValueAt(i, "pk_sfpara_set").toString();
if(edittingRowValue.equals(otherRowValue)){
e.getBillCardPanel().getBillModel().setValueAt(null, e.getRow(), "pk_sfpara_set");
e.getBillCardPanel().getBillModel().setValueAt(null, e.getRow(), "pk_sfpara_set.para_name");
MessageDialog.showErrorDlg(null, "提示", "压力因子不能重复,请重新选择");
return;
}
}
}
}
3.在对应的xml文件中配置即可
<!-- 表体编辑后事件 -->
<bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup">
<property name="event" value="nc.ui.pubapp.uif2app.event.card.CardBodyAfterEditEvent" />
<property name="handler">
<bean class="nc.ui.frm_alm.stress_test_plan.ace.handler.BodyAfterEditHandler" >
<property name="exceptionHandler"><ref bean="exceptionHandler" /></property>
</bean>
</property>
</bean>