0

Web 内容下,我将结构设置为具有应用程序字段:“记录媒体”。

通过这个字段,用户可以添加各种文件,然后显示在我的 .xhtml 中。

用户可以使此“文档和媒体”字段可重复以添加更多文件。

我如何遍历所有添加的文件并获取它们的相对路径。

如果我的 Documents and media 字段不可重复,我可以得到这样的相对路径:

    public String getWebContentTitle(String title, String nodeName) throws PortalException, SystemException {
        FacesContext context = FacesContext.getCurrentInstance();
        ThemeDisplay themeDisplay = (ThemeDisplay) context.getExternalContext().getRequestMap().get(WebKeys.THEME_DISPLAY);
        long groupId = themeDisplay.getScopeGroupId();
        JournalArticle article = JournalArticleLocalServiceUtil.getArticleByUrlTitle(groupId, formatUrlTitle(title));
        String languageKey = context.getExternalContext().getRequestLocale().toString();
        JournalArticleDisplay articleDisplay = JournalContentUtil.getDisplay(groupId, article.getArticleId(), article.getTemplateId(), languageKey, themeDisplay);
        JournalArticle journalArticle = JournalArticleLocalServiceUtil.getArticle(groupId, article.getArticleId());
        String myContent = journalArticle.getContentByLocale(languageKey);

        if (nodeName != null) {
            String nodeText=getParseValue(nodeName, journalArticle, myContent);
            return nodeText;
        } else
        {
            String ret=articleDisplay.getContent(); 
            return ret;
        }
    }

    private String getParseValue(String fieldname, JournalArticle article, String locale) {
        String nodeText = "";
        try {
              Document document = SAXReaderUtil.read(article.getContentByLocale(locale));
              Node node = document.selectSingleNode("/root/dynamic-element[@name='" + fieldname +"']/dynamic-content");
              nodeText = node.getText(); 
        } catch(Exception e){

        }
        return nodeText; 
    }

此方法返回我添加的文档的相对路径(例如 horses.pdf)。

我怎样才能获得通过“文档和媒体字段”添加的更多文档的相对路径,这是可重复的并且已经定义了特定的变量名称(比如 HorsesPdfs?)

任何帮助将不胜感激!

文档和媒体字段 - 可重复(图片上的绿色加号)

4

1 回答 1

1

你可以试试

DLAppLocalServiceUtil.getFileEntries(REPOSITORY_ID, FOLDER_ID), probably better than DLFileEntry as its the new approach that takes workflows in consideration.

在哪里

REPOSITORY_ID = parent group, which is by default LR´s one GroupLocalServiceUtil.getGroup(COMPANY_ID, GroupConstants.GUEST).getGroupId()

COMPANY_ID = PortalUtil.getDefaultCompanyId(); //If just one instance, if not, better to play with CompanyLocalServiceUtil to match your Id

对于文件夹 ID,您可以使用 LR´s Doc & Media 的 root 旧版本,即

FOLDER_ID = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID; //or find it e.g DLAppLocalServiceUtil.getFolder( repositoryId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_NAME).getFolderId();  if you programtically used addFolder(long userId, long repositoryId, long parentFolderId, String name, String description, ServiceContext serviceContext) 
于 2012-10-12T16:53:35.857 回答