Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Unable to iterate paragraph object in Sightly

Avatar

Avatar
Validate 10
Level 3
rohitn62196663
Level 3

Likes

12 likes

Total Posts

66 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile

Avatar
Validate 10
Level 3
rohitn62196663
Level 3

Likes

12 likes

Total Posts

66 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
rohitn62196663
Level 3

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
Validate 10
Level 3
rohitn62196663
Level 3

Likes

12 likes

Total Posts

66 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile

Avatar
Validate 10
Level 3
rohitn62196663
Level 3

Likes

12 likes

Total Posts

66 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
rohitn62196663
Level 3

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.