Essentially, just using the datatable indexes its entries by location in the list. So, as you've said, it'll just delete the "first row". There are actually worse situations. If you get the page, and while you're there, somebody ELSE deletes that first row, and then you click it, it'll just delete whatever row comes back first. No back button involved.
Solutions.
1 - JSF expects the rows of data to remain the same while you're looking at the page, so you could keep the table in the session. This is sort of the suggested standard. Its a bad plan. Back button still has the same problem.
2 - Use 'preserveDataModel'. I like this for some things. It keeps the data for the table in the view state, so when you click the entry it should pick up the correct one when you get back. I plan on doing some investigation today with the view storage on the server. I know that storing the view on the client always results in that data being stored correctly, but storing on the client has bad performance. I'm concerned that if the view is stored on the server that each time you go to the page the stored view gets wiped out. So for example, lets say you have a page that lists a folder structure. It shows the current folders, then you can drill down to sub-folders.
a - Go to FolderPage.jsf
b - Get list of root entries. Click on 'home'.
c - This takes you to the sub-folder page of 'home'.
d - Click back and select 'usr'
Not sure what would happen here if the state was stored on the server. Perhaps those better versed in the state storage can help? If one view is kept per-page per-session, then when we get to the 'home' directory, the table that is put into the view state with 'preserveDataModel' will be the table for the 'home' directory. When back is clicked, and 'usr' is selected, if there is only one view state stored, we would actually get the table for the 'home' directory when we're expecting the root dir. Again, I'm going to try this out today.
However...
3 - There's also 'forceIdIndexFormula'. This lets you specify what data element is the 'id' value for that row. This should work.
I plan on using a combination of 2 and 3 in my apps. The problem I have with 2 is that I use some hibernate objects directly, and I'm concerned about serialization. This is another topic that I need to research more myself.
Hope that helps.
-Kevin
On 8/21/06, Mr Arvind Pandey <[EMAIL PROTECTED]> wrote:
Hi,
I am using <t:dataTable> to display customer
info. Each row contains delete button also to delete
the info a particular customer. preserveDataModel
attribute of the datatable is set to false. Everything
working properly when i am going straight.
Now suppose I have 10 rows in the table and I
delete the first row , the first row gets deleted from
table and database also. But when I go back to
previous page using back button of Browser and try to
delete the first row again which has been deleted
already, then it deletes the next immediate row , I
mean second row.
If anyone can help me, I will be highly obliged.
Any suggestion will be appreciated.
Thanks and regards...
Arvind Pandey
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/

