(Key) rowSetIter.next() Raises a ClassCastException java.util.Collections$UnmodifiableRandomAccessList (Doc ID 434399.1)

Last updated on AUGUST 04, 2016

Applies to:

Oracle JDeveloper - Version: 10.1.3.0.4 and later   [Release: and later ]
Information in this document applies to any platform.

Symptoms


You developed an ADF Faces page with a Master table - Inline detail table and are trying to include a
TableSelectMany facet selection.

You can't get the selection made by the user.
If you change the application to include a simple af:table with just one level of information then it works fine.

The code is as described in the "Oracle Application Development Framework Developer's Guide 10g Release 3 (10.1.3)", section "7.6 Enable Row Selection in a Table", example 7-10.

public String commandButton1_action() {

//Access the tableSelectMany1 table. Note that the table name
//is taken from the id of the table in the JSF page.
CoreTable table = this.getTable1();

//Obtain a list of all selected rows from the table
Set rowSet = table.getSelectionState().getKeySet();
Iterator rowSetIter = rowSet.iterator();

//Use the declarative method to get the ADF bindings
BindingContainer bindings = getBindings();

//Get the object to delete. To do this, you must get the
//iterator binding for the Products in the page definition file,
//and cast it to DCIteratorBinding for further processing
DCIteratorBinding pr_dcib = (DCIteratorBinding) bindings.get ("findAllProductsIter");

//Loop through the set of selected row numbers and delete the
//equivalent object from the Products collection.
while (rowSetIter.hasNext()){
//get the table row
Key key = (Key) rowSetIter.next();

(...)

This code only works for a simple table. With a Master Table - Inline Detail Table it gives an
exception in the line:

        Key key = (Key)keyIter.next();


and raises the following error:
   java.lang.ClassCastException:
java.util.Collections$UnmodifiableRandomAccessList

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms