My DataModel or DataModelSelection is not behaving properly in multiuser operations.
Lets say I have populated a DataModel with 5 entities.
Now, I render this list with JSF DataTable on UI (for user 1)
At the same time, user 2 starts the application and views the same list with 5 entities.
Now user 1 deletes entity 1 from the list and gets the refreshed list with 4 entities.
But user 2 does not know about the modification done to the list and tries to view the details of entity 1 (which is not there in the list). But after selecting entity 1 of previous list, user 2 is getting the details of entity 1 of the refreshed list (previously entity 2).
How can I solve this problem ?
I could think of maintaining a class level variable which would keep a track of modifications to the list (DataModel), similar to what version number does in Hibernate.
But that would be a crude way of doing a workaround.
Is there any standard way of handling this situation ?
Got it solved.
The problem occurs because my seam components (which own the DataModels) are in CONVERSATION scope.
Before the actual method which fetches details of an entity gets executed, factory method is called which repopulates DataModel.
Once I changed the scope to SESSION, I get the expected behavior.