It happens to develop such screens, where users can browse through table rows, select any row and using related form update selected row data. Thinking from pure end-user approach, when data table contains many columns, sometimes its easier to edit row data in separate form. Everything is fine with this approach, however there is one thing that can be confusing to the end-user. Let's say, user is editing row data and then suddenly selects another row from the table, without saving changes from previous row. In such way, user can end up with changes in many rows and will loose track what should be saved and what reverted. This use case is from real life.
In order to avoid user confusion with changes in multiple rows, I have developed sample application - TableAutoCommit.zip. This application implements read-only table and editable form, which brings data from currently selected row. Main trick - if user will edit data from selected row and will select another row without saving or reverting his changes, changes will be saved automatically - this will allow end-user to keep track of his changes easier. Of course, its not generic solution and should not be applied everywhere, it should be applied only if its really needed in specific case.
In this example, user selects first row from the table, editable form allows to change selected attributes:
Then he enters phone number:
And selects another row without saving changes he did:
Changes will be saved automatically and message will appear to inform user about latest commit:
When there are no pending changes, user can select any rows, nothing happens:
I will describe how it is implemented - really easy with ADF 11g. Only thing you need to have is custom SelectionListener for table component:
Also there should be method to determine unsaved changes. You can check if there are any, just with ADF standard method - isDirty():
Lastly, if there are unsaved changes, invoke commit operation and display information message. Otherwise, just proceed to the next row selection: