0

我正在尝试使用 JAVA USE API 和 Sightly 迭代段落列表(com.day.cq.wcm.foundation.Paragraph)。它能够在后端获取段落。但是它无法读取它并将其显示在前端。

下面是代码:

爪哇:

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>

我正在尝试从基础段落类中获取段落类型。但它能够识别大小并迭代“n”次,但无法显示该值。

注意:Paragraph 不是自定义类,它是 cq 基础类,即 com.day.cq.wcm.foundation.Paragraph;

4

1 回答 1

1

如果您查看 JavaDocsParagraphgetType()返回值,我猜想 HTL 无法解释该枚举。你可以尝试的是 -

paragraphs.type.name
于 2016-11-11T14:03:03.627 回答