在GWT中恢复(撤消)实施 [英] Revert (Undo) implementation in GWT

查看:121
本文介绍了在GWT中恢复(撤消)实施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试使用GWT构建一个GUI框架。我们发现很难在框架中实现取消功能。



需要的功能是这样的:



我们的CRUD屏幕有弹出窗口,网格等等。当用户改变GUI中的任何内容,然后点击cancel()时,他应该收到一条通知消息,指出事情已经发生变化。



我们尝试过的方法:



目前我们正在尝试保留整个pojo对象的key vs value的hashmap,并试图将其与在用户更改某些内容时进行更新的模型进行比较。但是,这会在每个pojo中添加大量不需要的代码,并且在用户直接从后端添加数据时无法按预期工作。



有没有实现此功能的优雅方法?请注意, * 我们没有使用GWT *编辑器框架 (https://developers.google.com/web-toolkit/doc/latest/DevGuideUiEditors)例如:
假设我有这样的pojo:

  $ b $ code> public class Person {

List< Address>地址;
PhoneNumber phoneData;


//等等以及getter和setters

}

我将如何为此编写一个通用克隆方法?即使我设法做到这一点,会导致在每个pojo(我们的应用程序有数百个)很多代码看起来不正确。



请注意,只要GUI中的某些内容发生更改以实现实时绑定,我们的pojo就会更新。

解决方案

所以你的表单中有保存和取消按钮?



我会建议你改变这个概念。用户在OnChange事件处理程序中编辑它们(如在GMail,JIRA和许多其他现代应用程序中),立即更新您的对象属性。


$ b

将会话堆栈的所有更新保存为UpdateAction对象,并让用户撤消每一个调用UpdateAction.undo()方法的属性修改。



好处是:


  1. 此设计比点击编辑更新 - 点击保存场景更方便用户使用。


  2. 您不需要单独的查看/编辑表单/弹出式对话框 - 仅用于查看和编辑的单一表单。



We are trying to build a GUI framework using GWT. We are finding it hard to implement the cancel functionality in the framework.

Required feature is this:

We have CRUD screens which have pop-ups, grids and so on. When the user changes anything in the GUI and then clicks on cancel() he should be given a notification message saying that something has changed.

Approach that we have tried:

Currently we are trying to keep a hashmap of key vs value of the entire pojo object and trying to compare it against the model which gets updated as and when user changes something. But this is adding lot of unwanted code in every pojo and not working as expected when user adds data directly from the backend.

Is there any elegant way in achieving this functionality? Kindly note that *we are not using Editor framework of GWT *(https://developers.google.com/web-toolkit/doc/latest/DevGuideUiEditors) in our application.

Example: Suppose I have a pojo like this:

public class Person {

    List<Address> address;
    PhoneNumber phoneData;


    // and so on along with getters and setters

}

How will I write a generic clone method for this? And even if I manage to do that somehow that will lead to lot of code in every pojo (our application has hundreds of them) which doesn't seem right.

Please note that, our pojo gets updated as soon as something is changed in GUI to achieve live binding.

解决方案

So you have "Save" and "Cancel" buttons in your form?

I would recommend you to change the concept. Update your object properties immediately as user edit them (as in GMail, JIRA and many other modern applications) in an OnChange event handler.

Save all updates to the session stack as UpdateAction objects and let the user undo every single property modification calling UpdateAction.undo() method.

The benefits are:

  1. this design is much more user friendly than "Click "Edit" - update - click "Save"" scenario.

  2. You don't need separate view/edit forms/popup dialogs - just a single form for both viewing and editing.

这篇关于在GWT中恢复(撤消)实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆