I have a requirement to populate dynamic dropdown with checkboxes. I can able to populate dynamic values but along with that checkboxes also has to be populated.
public void doGet(SlingHttpServletRequest req, SlingHttpServletResponse res) {
List<Resource> resourceList = new ArrayList<>();
resolver = req.getResourceResolver();
req.setAttribute(DataSource.class.getName(), EmptyDataSource.instance());
lobResource = resolver.getResource(acsPathLOB);
String key = StringUtils.EMPTY;
String value = StringUtils.EMPTY;
for (Resource resource : lobResource.getChildren()) {
key = resource.getValueMap().get("jcr:title", String.class);
value = resource.getValueMap().get("value", String.class);
valueMap = new ValueMapDecorator(new HashMap<>());
valueMap.put("text", key);
valueMap.put("value", value);
try {
resourceList.add(new ValueMapResource(resolver, new ResourceMetadata(),
"/libs/granite/ui/components/coral/foundation/form/checkbox", valueMap));
} catch (Exception ex) {
log.error("--exception--:{}", ex.getMessage());
}
}
DataSource ds = new SimpleDataSource(resourceList.iterator());
req.setAttribute(DataSource.class.getName(), ds);
}
but only values are getting populated any suggestions to populate as checkboxes.
Thanks in advance,
Keerthi K.