Liferay 如何通过Portlet在Web Content下创建文件夹及子文件夹
Web Content模块的文件夹创建需要使用JournalFolderService提供的API,具体实现步骤如下:
实现步骤
- 注入
JournalFolderService服务引用
@Reference private JournalFolderService _journalFolderService;
- 构造接口所需参数,参数说明如下:
groupId:当前站点ID,可通过ThemeDisplay的getScopeGroupId()方法或者ParamUtil从请求中获取parentFolderId:父文件夹ID,若需要创建根层级文件夹直接传0即可name:文件夹名称description:文件夹描述信息serviceContext:服务上下文对象,可通过ServiceContextFactory构造
示例参数获取代码:
// 示例从请求中获取参数 long groupId = ParamUtil.getLong(actionRequest, "groupId"); long parentFolderId = ParamUtil.getLong(actionRequest, "parentFolderId", 0L); String name = ParamUtil.getString(actionRequest, "name"); String description = ParamUtil.getString(actionRequest, "description"); ServiceContext serviceContext = ServiceContextFactory.getInstance( JournalFolder.class.getName(), actionRequest);
- 调用接口创建文件夹
JournalFolder webContentFolder = _journalFolderService.addFolder( groupId, parentFolderId, name, description, serviceContext);
配套Web Content导入说明
完成文件夹创建后,你可以通过JournalArticleService的addArticle接口导入Excel读取到的内容,调用时传入上面创建得到的webContentFolder.getFolderId()作为文件夹参数,即可将内容存入对应文件夹。
内容的提问来源于stack exchange,提问作者skdonthi
相关产品推荐
相关产品推荐

