问题描述
在我的应用程序中,我有一个路径可以从网页的页面属性部分的 dam 内容中获取 pdf 文件,并且我们有一个下载组件,如果文件存在,它会尝试显示 pdf 文件的标题和描述。我使用这篇文章作为参考:http://jenikya.com/blog/2014/05/file-titles-cq.html。 我的 HTL 部分就像:
<div data-sly-test="${pageProperties.pdfFileReference}" class="download-container ${properties['backgroundColor']}">
<sly data-sly-use.pdfInfo="${'xx.xxx.PDFInfoDataProvider @ pdfPath=pageProperties['pdfFileReference']}">
<a class="download-title" href="${pageProperties.pdfFileReference}" data-analytics-cta-text="${pdfInfo.fileTitle}">
<span class="download-title">${pdfInfo.fileTitle}</span>
</a>
<div class="download-description">${pdfInfo.fileDescription}</div>
</sly>
</div>
我的 java 部分如下所示。看起来它永远不会得到标题和描述。如果有人可以帮助指出可能存在的问题,或在任何地方寻找解决方案,我将不胜感激。
package ....
import ....
public class PDFInfoDataProvider extends WCMUsePojo {
private String fileTitle;
private String fileDescription;
private String pdfPath;
@Override
public void activate() throws Exception {
pdfPath = get("pdfPath",String.class);
resolve();
}
private void resolve() {
Resource resource = getResourceResolver().getResource(pdfPath);
Asset asset = resource.adaptTo(Asset.class);
String title = asset.getMetadataValue("dc:title");
String description = asset.getMetadataValue("dc:description");
fileTitle = title;
fileDescription = description;
}
public String getTitle() { return fileTitle; }
public String getFileDescription() { return fileDescription; }
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)