Eclipse DataBinding:延迟模型更新直到对话框确认
我有一个带有默认按钮的 TitleAreaDialog,我在其中使用数据绑定来同步模型和小部件。如何延迟模型更新直到用户单击“确定”按钮?
谢谢!
I have a TitleAreaDialog with default buttons where I use data binding to synchronize the model and the widgets. How do I delay model updates until the user clicks the 'OK' button?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道怎么拖延。另一种方式是注册 DisposeListener 以检查用户选择“确定”或“取消”。如果结果不好,我就会放弃改变。
就我而言,我绑定了从 hibernate 获取的模型。当“确定”时是否保持休眠状态,当按下取消时是否刷新模型(从数据库中重新读取数据)。
但是,我也希望该函数能够延迟或撤消更改。
I don't know how to delay. In another way, to register the DisposeListener to check the user select ok or cancel. If the result is not ok, I give up the changes.
In my case, I binded the model fetched from hibernate. Do hibernate persist when 'ok', do refresh model (re-read data from database) when cancel is pressed.
However, I want the function to delay or undo changes, too.
您必须为绑定设置
POLICY_CONVERT
或POLICY_ON_REQUEST
的UpdateValueStrategy
来“延迟”模型更新:然后您可以通过像这样的“确定”按钮:
或者您可以通过调用
DataBindingContext.updateTargets()
来更新DataBindingContext
中的所有绑定You have to set the
UpdateValueStrategy
ofPOLICY_CONVERT
orPOLICY_ON_REQUEST
for your binding to 'delay' the model updates:Then you can update the target via the OK button like this:
Or you can update all bindings within the
DataBindingContext
by callingDataBindingContext.updateTargets()