vaadin8 - Vaadin 8.4.0 Modal for save confirmation after grid buffer save
问题描述
We are using a grid to present some data. This grid is not using a data provider but setting its items.
We are working on buffered modd, but we still want to show a modal informing what are we about to save, with the posibility to save or cancel.
SaveEditor method has been removed from grid class in our current version (8.4.0), so cant do it that way.
I have come to a close solution but with some remaining problems. I have extended grid component to be able to create my own editor:
public class MyGridComponent extends Grid<MyData> {
public MyGridComponent (Class<MyData> beanType) {
super(beanType);
}
@Override
protected Editor<MyData> createEditor() {
return new MyGridEditor(this.getPropertySet());
}
}
On my editor I have overriden following methods:
@Override
protected void doEdit(OutcomeWagerLimit bean) {
copyMyBean = bean;
super.doEdit(bean);
}
@Override
public boolean save() {
String desc = copyMyBean.getDescription();
StringBuilder captionBuilder = new StringBuilder()
.append("Save ")
.append(desc)
.append("?");
StringBuilder messageBuilder = new StringBuilder()
.append("Do you really want to save ")
.append(desc)
.append("?");
openConfirmMsgBox(captionBuilder.toString(), messageBuilder.toString(),() -> super.save(), ()->super.cancel());
return true;
}
With this code clicking on save opens my confirmation modal. If clicking on save, everything works flawlessly, but clicking on my modal cancel which will call to EditorImpl.cancel() method, acts in a weird way. Clicking cancel on my modal will close edition mode, but if I edit again any other row (double clicking on it) grid's save and cancel buttons (not the modal ones) stop working. Not launching any request from client to vaadin's servlet.
Does anyone know any possible solution to this or a better way to reach what I'm trying to achieve?
Thanks in advance
解决方案
Morning,
Just managed to do it. Since not using dataprovider but normal list, I am the one responsible of saving data in other saveEventListener. That is the moment to present modal and in the "ok" case persist it in database.
So there is no need to override EditorImpl save method and do it in a saveEventListener.
Thanks
推荐阅读
- javascript - 我无法在 Alpine JS 中确定此消息的原因
- python - 列表中的Python奇数
- c++ - 在 Ubuntu 中为子进程使用 Fork() 和 Exec()
- angular - Ionic 5 - 将在 Android/iOS 上的 Ionic/Capacitor 应用程序的锁定屏幕方向
- sql - 在一列中加入 2 个带有分类标签的表
- docker - docker:无效的引用格式,变量名包含`=`
- sql-server - SSIS 将平面文件值与 SQL Server 查找表的最小值最大值进行比较以查找值
- python-3.x - Python3 - 如何在 kivymd 中加载文件?(并将其路径存储为字符串)
- c++ - 试图将 3d 数组传递给函数 c++
- ruby - 在同一行接收值