beforeUpload取消上传插件示例介绍
# 1 业务场景
适用于需要取消附件上传的场景
# 2 解决方案
可以通过附件上传前事件 BeforeAttachmentUploadListener 取消附件的上传
# 3 操作步骤
代码示例如下
```java
public class AttachmentDemand_BeforeUpload extends AbstractFormPlugin implements BeforeAttachmentUploadListener {
private static final String BOS_ATTACHMENT = "bos-attachment";
//附件字段
private final static String KEY_ATTACHMENTFILED = "my_attfield";
//附件面板
private final static String KEY_ATTACHMENTPANEL = "attachmentpanel";
@Override
public void registerListener(EventObject e) {
AttachmentEdit attachmentEdit = this.getView().getControl(KEY_ATTACHMENTFILED);
AttachmentPanel attachmentPanel = this.getView().getControl(KEY_ATTACHMENTPANEL);
//监听上传前事件
attachmentEdit.addBeforeUploadListener(this);
attachmentPanel.addBeforeUploadListener(this);
}
@Override
public void beforeAttachmentUpload(BeforeAttachmentUploadEvent evt) {
//取消上传之前的附件
List<Map<String, Object>> sourceAttachments = evt.getSourceAttachments();
//设置需要取消上传的附件集合
evt.getCancelAttachments().add(sourceAttachments.get(0));
//是否取消
evt.setCancel(true);
//取消成功的提示语
evt.setMsg(ResManager.loadKDString(
"取消上传第一个文件成功。", "AttachmentDemand_BeforeUpload_1", BOS_ATTACHMENT));
}
}
```
beforeUpload取消上传插件示例介绍
# 1 业务场景 适用于需要取消附件上传的场景# 2 解决方案 可以通过附件上传前事件 BeforeAttachmentUploadListener 取消附件的上传...
点击下载文档
本文2024-09-23 00:39:05发表“云苍穹知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-cangqiong-140843.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章