Avatar

Level 3

Hi Arun,

Thanks for the response. As you suggested putting  vm.put("selected",true), The code started breaking with the below exception. It successfully set the selected to true but later it break and once i remove the selected to true it works fine

Can you kindly guide or share your code snippet. Also below sharing my lines of code.

Code

ValueMap labelValues = new ValueMapDecorator(new HashMap<String, Object>());

String labelKey = (String)labelhit.getResource().getValueMap().get(FollettConstants.LABELKEY_PROPERTY,null);

if(! StringUtils.isEmpty("author_by_prefix") && "author_by_prefix".equals(labelKey)) {

labelValues.put("selected", true);

}

labelValues.put("text", labelKey);

labelValues.put("value", labelKey+FollettConstants.HASH_SEPRATOR+labelhit.getPath());

labelList.add(new ValueMapResource(resourceResolver, new ResourceMetadata(),

     "nt:unstructured", labelValues));

    DataSource dataSource = new SimpleDataSource(labelList.iterator());

            request.setAttribute(DataSource.class.getName(), dataSource);

Exception

  23.07.2018 01:36:55.941 *ERROR* [0:0:0:0:0:0:0:1 [1532289997383] GET /mnt/override/apps/follett/components/content/labeldemo/pdpmappedlabels/_cq_dialog.html/content/follett/en/tcustore/pdppage/jcr:content/par/pdpmappedlabels HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught SlingException

org.apache.sling.api.request.RecursionTooDeepException: /mnt/override/apps/follett/components/content/labeldemo/pdpmappedlabels/cq:dialog/content/items/mappedlabel/items/column/items/addtobag

at org.apache.sling.engine.impl.request.RequestData.setContent(RequestData.java:571) [org.apache.sling.engine:2.6.12]

at org.apache.sling.engine.impl.SlingRequestProcessorImpl.dispatchRequest(SlingRequestProcessorImpl.java:311) [org.apache.sling.engine:2.6.12]

at org.apache.sling.engine.impl.request.SlingRequestDispatcher.dispatch(SlingRequestDispatcher.java:211) [org.apache.sling.engine:2.6.12]

at org.apache.sling.engine.impl.request.SlingRequestDispatcher.include(SlingRequestDispatcher.java:104) [org.apache.sling.engine:2.6.12]