1、简单介绍调用预置的操作的调用链
以submit为例
(1)插件调用跟踪,代码
import java.util.EventObject;
import com.kingdee.bos.ctrl.common.util.StringUtil;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.list.plugin.AbstractListPlugin;
public class TestListDemoPlugin extends AbstractListPlugin{
@Override
public void registerListener(EventObject e) {
this.addItemClickListeners("toolbarap");
}
@Override
public void itemClick(ItemClickEvent evt) {
String key = evt.getItemKey();
if (StringUtil.equals("kdec_baritemap2", key)) {
//最后还是执行了 OperationServiceHelper.executeOperate
this.getView().invokeOperation("submit");
}
}
(2)调试代码
ListView.class
AbstractListView.class
FormView.class
FormOperate.class
DefaultEntityOperate.class
OperationServiceHelper.class
DispatchServiceHelper.class
kd.bos.service.ServiceFactory
OperationServiceImpl.class
EntityOperateService.class
方法:doExcete
方法:callOperationTransaction
方法:callOperation
这个executeOperate方法是在操作执行类里面实现的
Submit extends StatusConvertOperateService
StatusConvertOperateService extends EntityOperateService
submit.class的路径kd.bos.service.operation.Submit
StatusConvertOperateService.class
秒懂~~~为什么执行提交操作没有进行保存操作配置的校验尼
2、 SaveServiceHelper帮助类方法save(dataEntities)和saveOperate(entityNumber, dataEntities, option)的区别
(1)save方法通过事务,调用BusinessDataWriter.save(dataEntities[0].getDataEntityType(), dataEntities);把数据保存到数据库了
(2)saveOperate调用OperationServiceHelper.executeOperate(operations.getSave() == null ? "save" : operations.getSave(),entityNumber, dataEntities, option);就是和表单自带的操作一样,会对配置的校验规则进行校验,把数据同步到前端
备注:在A页面使用SaveServiceHelper.save保存B单的数据,在B单列表上没显示,需要刷新一下~~
推荐尽量使用saveOperate
掉服务接口去了...
【emoji】
推荐阅读