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」を介して追加されたドキュメントへの相対パスを取得するにはどうすればよいですか?
どんな助けでも大歓迎です!