How to select last row inserted in table binded to SQLContainer

I have this code

Object itemId = table.addItem();
container.getContainerProperty(itemId, “cedula”).setValue(cedulaS);
try {
catch (UnsupportedOperationException e) { //bla }

The above code insert a row in a table and commits ii to the database BUT the problem is that the line;

is not working because it is a temporary itemId.The documentation said
"Implement QueryDelegate.RowIdChangeListener to receive the actual Row ID value after the addition has been committed. "

But I dont undertand how to do this.



try something like this:

container.addRowIdChangeListener(new QueryDelegate.RowIdChangeListener() {
   void rowIdChange(QueryDelegate.RowIdChangeEvent event) {;

THIS WAS AN ERROR ";" is NOT working I will try your example, Teppo.

I finded a partial solution like this:

Object itemId = table.addItem();
Item item = containerBindTotable.getItem(itemId);
container.getContainerProperty(itemId, "cedula").setValue(cedulaS);
try {
   container.commit();; // this works, it is selected, BUT it doesnt scroll to it
catch (UnsupportedOperationException e) { //bla }

BUT there is a problem: supposed the table show 5 rows (lines) but have 10 rows, if I inserted one more, it is selected, BUT it doesnt automatically, the user have to scroll down until he/she find the row selected.

Thanks it works perfectly!