wicket - Handling simultaneous action
问题描述
I have a GUI screen which consist of 2 buttons, Check Balance and Create Saving. Once any user enters the customer ID and click on 'Check Balance' , details of the customer including their balance will be shown and simultaneously 'Create Saving' button will be enabled(after clicking on 'Check Balance' button as initially it will be disabled).
I have an scenario which i will try to explain with an example :
There are 2 users X & Y, who have logged in at the same time, and have clicked the "Check Balance" at the same time for a customer Id say 12345. Both see customer balance including some more details about customer and the "Create Saving" button is enabled for both of them.
- User X decides to take a break, and does not create a Saving, but User Y creates a Saving.
- User X comes back and click on the "Create Saving" button. **Now the question is how the X should be allowed to see updated value ? (OR) a Check Balance should be forced to X (OR) a warning message should be shown for X to check Balance ? **
every time a saving is created, technically "Check Balance" are always invoked, thus always refreshed values are considered before creating a saving in the back end. In the above scenario, though the User X sees outdated value in the screen, the saving is always created considering the saving created by User Y.
Any suggestion will be much appreciated.Thanks.
解决方案
when you click on "Create Saving" you could send the outdated amount or a timestamp indicating when it was retrieved. Then on server side when "Check Balance" is invoked you could check if the actual amount has changed and if so, you might redirect user to an intermediate page informing him/her and asking if the saving operation should be aborted or not.
Hope this could help.
推荐阅读
- docker - docker build certbot 电子邮件输入
- google-cloud-firestore - Firebase 应用程序在 Google Cloud Build 的测试阶段挂起
- mysql - 选择特定日期或之前的数据
- realm - 从结果中过滤最高数值
- javascript - 循环 JSON 时无法在 Javascript 中使用 IN 运算符
- xml - 如何将 XML Powershell system.object[] 数组导出到 CSV 文件
- sql - 增量 SQL 查询的 AWS 等效项
- ios - 查看协调员/代表消失功能?
- .net - ASP.NET Core 3 MVC:对象列表的模型绑定
- node.js - 跨托管在同一域上的多个节点红色实例维护会话