Unable to iterate paragraph object in Sightly

Avatar

Avatar

rohitn62196663

Avatar

rohitn62196663

rohitn62196663

10-11-2016

I am trying to iterate a list of paragraphs(com.day.cq.wcm.foundation.Paragraph) using JAVA USE API and Sightly. However it displays an empty list in the front end.

Below is the code:

Java:

public class AnchorList extends WCMUsePojo{ private List<Paragraph> paragraphs; public List<Paragraph> getParagraphs() { return paragraphs; } public void setParagraphs(List<Paragraph> paragraphs) { this.paragraphs = paragraphs; } public void activate() throws Exception{ paragraphs = new LinkedList<Paragraph>(); Resource resource = getResource(); SlingHttpServletRequest slingRequest = getRequest(); ParagraphSystem parSys = ParagraphSystem.create(resource, slingRequest); for (Paragraph par: parSys.paragraphs()) { paragraphs.add(par); } } }
HTML:<div data-sly-use.anchorList="AnchorList" data-sly-unwrap> <div data-sly-list.paragraphs="${anchorList.paragraphs}" data-sly-unwrap> Para Type is: ${paragraphs.getType} </div> </div>

 

I am trying to get the type of paragraph from the foundation paragraph class. But its able to identify the size and iterating 'n' times but its not able to display the value.

Note: Paragraph is not a custom class, its the cq foundation class i.e. com.day.cq.wcm.foundation.Paragraph;

View Entire Topic

Avatar

Avatar

rohitn62196663

Avatar

rohitn62196663

rohitn62196663

10-11-2016

Sightly is unable to read the data in paragraphs list. Its able to get the paragraphs in java and I am adding that paragraphs to a linked list and sending it to HTML. But Its not displaying the values in front end. I suspect its unable to read that paragraph object itself in front end.