use of com.adobe.granite.ui.components.ds.ValueMapResource in project acs-aem-commons by Adobe-Consulting-Services.
the class DataSourceBuilderImpl method addDataSource.
@Override
public void addDataSource(final SlingHttpServletRequest slingRequest, final List<DataSourceOption> options) {
final ArrayList<Resource> resourceList = new ArrayList<Resource>();
DataSource dataSource = null;
for (final DataSourceOption option : options) {
final Map map = new HashMap();
map.put(TEXT, option.getText());
map.put(VALUE, option.getValue());
resourceList.add(new ValueMapResource(slingRequest.getResourceResolver(), new ResourceMetadata(), "", new ValueMapDecorator(map)));
}
if (resourceList.size() > 0) {
dataSource = new SimpleDataSource(resourceList.iterator());
} else {
dataSource = EmptyDataSource.instance();
}
slingRequest.setAttribute(DataSource.class.getName(), dataSource);
}
Aggregations