The ADF framework boasts some pretty sweet built-in functionality when it comes to user driven events. However, the table selection functionality that is currently built-in has some potential for improvement. When a user selects a specific row, there are a number of potential scenarios that I may want to code for. For example, I may want to do a combination of the following:
- Refresh one or more tables based on the user's selection.
- Update the URL of a button’s action with one or more parameters from the selected row.
- Fill out additional input components on the page.
- Perform validation on the user’s selection. For example, if the user selects a row to either delete or edit. We can perform custom validation to see if that row meets specific criteria.
- Set a value into the session.
ADF/UIX simply does not have the built-in functionality to efficiently handle a combination of these events. With this in mind, I recommend creating a custom Java event with the combination of Oracle’s Partial Page Refreshing to handle the action of a user selecting a row in a UIX table. Let’s take a look at how to do this.
Within the UIX tags of your table, you will need to look for the
Once the UIX page is configured, we can then create our method in the action class. Please note that you will need to know the UIX ID attribute of your table as well as the name of the table’s iterator. The best way to show you this is by looking at the code. Our method should look something like this:
public void onMySelect(DataActionContext actionContext)
{
//grab the instance of the table
ServletRequestDataSet tableDataSet = new
ServletRequestDataSet(actionContext.getHttpServletRequest(),
"theIdOfTheTableInTheUixPage");
//get the index of the row that the user has selected
int selectedIndex = SingleSelectionBean.getSelectedIndex(tableDataSet);
//find the iterator associated with the table
JUIteratorBinding itBinding =
((JUIteratorBinding) actionContext.getBindingContainer()
.findNamedObject("theTablesIterator"));
//set the iterators row equal to the row that the user has selected
itBinding.setCurrentRowIndexInRange(selectedIndex);
//make sure the selected row is valid
if (itBinding.getCurrentRow() != null)
{
//perform all necessary actions on the selected row.
}
}
After looking at the above, I hope that it is apparent that the above solution will provide you with a customized, yet scalable approach when dealing with UIX table interactions.