Showing posts with the label CurrentRow

Get current row from ADF UI attribute

Source: GitHub

This is a quick blog post which showcases the power of ADF UI components' attribute. Alternatively, this blog post could also have had a heading of "Getting current row when af-table's row selection is disabled", but I randomly chose the former.

A typical use-case for such a requirement could be that the customer does not want any row selection, in order to improve the page performance, as every row selection change calls for a server trip wherein lot of information gets stored on the ADF framework.

But we also need a mechanism where, if an editable attribute of the ADF table is modified, we should be able to extract the row on which the operation was performed. Since row selection is disabled, the framework has no information of current row.

Here is where we can make use of <f:attribute>. We create a new attribute on the editable column, which holds "#{row}" value. This row expression comes from var attribute of the A…

Set current row after commit/rollback (with a twist)

One of the most common requirements from user experience perspective is to keep the currently edited row selected after commit or rollback, or mark the newly created row as the current row.
For edit use-case, this is quite simple to achieve. Step 1: Store the current row key. Step 2: Edit record and commit. Step 3: Execute query. Step 4: Set the old row as the current row in the Row Set.
Here's a code snippet:

Does this logic holds good for new rows?. Well yes, almost!

Imagine this scenario:
1. You have a table of employees with a search option.You have searched for department id 10. That shows up all employees from department id 10.
2. Now you create a new employee, but this time, for department 20.
3. Now, after commit, you try to set the set the new row as the current row.
Now you get an exception! oracle.jbo.RowNotFoundException: JBO-25020:View row of key oracle.jbo.Key[201] not found in EmployeesVO1Iterator.

Quite obvious, isn't it? The new employee from department 20 does not exist …