简体   繁体   中英

Spring Boot + React: reload application tabs when data has been posted to the server on one of the tabs

I'm making a Spring Boot + React application.

Let's say I opened 2 identical tabs with Update Employee component: like on a screenshot

I made some changes on one of the tabs. I sent data to the server by clicking Save button.

The problem is that I don't want to let user go to the second tab with old data loaded on the form. The user might click Save an the old data will override recently posted data. And therefore no changes will be made.

What is a mechanism to reload/rerender all the other tabs after data has been posted to the server on one of the tabs? So there will be the actual data shown everywhere.

Or are there some patterns to do it in a proper way?

Your problem will be solved with using optimistic locking and versioning your entities in the database. If you're using jpa please refer to this post

https://www.baeldung.com/jpa-optimistic-locking

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM