Getting an iterator and passing through it

Here you have some code for getting the iterator by name go through the values.

DCIteratorBinding iter = findIterator(“YOUR_ITERATOR_NAME”);

Row[] rows = iter.getAllRowsInRange();
for (Row row : rows) { // do something here }

/**
* Find an iterator binding in the current binding container by name.
*
* @param name iterator binding name
* @return iterator binding
*/
public static DCIteratorBinding findIterator(String name) {
DCIteratorBinding iter = getDCBindingContainer().findIteratorBinding(name);
if (iter == null) {
throw new RuntimeException(“Iterator ‘” + name + “‘ not found”);
}
return iter;
}

/**
* Return the current page’s binding container.
* @return the current page’s binding container
*/
private static BindingContainer getBindingContainer() {
BindingContext bc = BindingContext.getCurrent();
return bc.getCurrentBindingsEntry();
}

/**
* Return the Binding Container as a DCBindingContainer.
* @return current binding container as a DCBindingContainer
*/
public static DCBindingContainer getDCBindingContainer() {
return (DCBindingContainer)getBindingContainer();
}

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s