0

Web コンテンツの下で、構造体にアプリケーション フィールド「Documents an media」が含まれるように設定しました。

このフィールドを介して、ユーザーはさまざまなファイルを追加できます。これらのファイルは、.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) への相対パスを返します。

「Documents and media field」を介して追加されたドキュメントへの相対パスを取得するにはどうすればよいですか?

どんな助けでも大歓迎です!

ドキュメントとメディア フィールド - 繰り返し可能 (画像に緑のプラス)

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

FOLDER ID には、LR の Doc & Media の古いルートを使用できます。

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 に答える