webtier@glassfish.java.net

HtmlDataTable.getRowData(), row indices

From: Uwe Seimet <Uwe.Seimet_at_seimet.de>
Date: Mon, 6 Oct 2008 11:18:01 +0200

Hello!

In my web application I have a managed bean in request scope. This bean
uses an HtmlDataTable instance. The data table wraps data in a database.
When two users are logged in I have the following problem:
Both users A and B have independent views of the same data, based on
their managed beans. They each see a data table with identical content:

Row 1
Row 2
Row 3

Now user A triggers an action that deletes Row 2 from the database.
After updating the view for user A only Row 1 and Row 3 are left in the
data table, which is fine:

Row 1
Row 3

User B still sees his copy of the data table containing three Rows. User B
now triggers an action that tries to delete what he sees as Row 2 in his view
from the database. The result is that Row 3 is now deleted, most likely
because the row indices have changed in the meantime.

Is there a way to address this problem of row indices changing? Can I add
additional information like the database ID to each row of the data table
in order to get a kind of mapping independent of "physical" row IDs?
Or are there any other solutions to this problem?

Best regards Uwe