Programmatically adding objects to an Iterator for ADF or BPM Arrays

This one took a week to figure out as I was new to ADF at the time but here it is:

Main Method:

//Iterate Control Tests
DCBindingContainer iteratorBindings =
(DCBindingContainer) BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding myIterator= iteratorBindings.findIteratorBinding(“dataControlIterator”);

RowSetIterator rsi = myIterator.getRowSetIterator();

for (MyObject object : myObjectList) {
Row lastRow = rsi.last();

int lastRowIndex = rsi.getRangeIndexOf(lastRow);

Row newRow = rsi.createRow();

newRow.setNewRowState(Row.STATUS_INITIALIZED);

newRow = setRowEditable(newRow);

newRow.setAttribute(“attributeName”, object .getId());

 

rsi.insertRowAtRangeIndex(lastRowIndex + 1, newRow);

rsi.setCurrentRow(newRow);

myIterator.getDataControl().commitTransaction();
}

Utility Methods:

public Row setRowEditable(Row row) {
int attribCount = row.getAttributeCount();
for (int i = 0; i < attribCount; i++) {
ViewAttributeDefImpl attrDef = (ViewAttributeDefImpl) row.getStructureDef().getAttributeDef(i);
attrDef.setEditable(true);
attrDef.setSDOHidden(false);
attrDef.setUpdateableFlag(ViewAttributeDefImpl.UPDATEABLE);
}
return row;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s