我正在尝试获取页面结构名称。我制作了钩子(Hook)并编写检查每个页面结构名称。
我用过JournalStructureLocalServiceUtil.getStructure()
但它不起作用并给了我错误,当我使用 JournalStructureLocalServiceUtil.getStructures()
时它给了我结果
[{uuid=6e12b579-c03e-4bd1-a4b3-45c6259807c7, id=10802,groupId=88,
companyId=1, userId=2, userName=Haider Ghaleb, createDate=Wed Sep 05 12:23:43 GMT
2012, modifiedDate=Mon Sep 10 16:23:46 GMT 2012, structureId=10801,
parentStructureId=, name=Restriction, description=Testing testing, xsd= }]
在这里我可以找到结构名称“Restriction”。任何人都可以帮助我,我也用过
BeanParamUtil.getString(article, request, "structureId")
BeanParamUtil.getLong(article, request, "groupId", scopeGroupId)
获取结构ID和组ID。
最佳答案
您已经快要知道该结构的名称了!尝试以下代码:
String structureName = JournalStructureLocalServiceUtil.getStructure(groupId, structureId).getName(Locale.US, true);
其中“groupId”和“structionId”是您通过 BeanParamUtil 获取的或按照 Prakash 建议的(这也是一种更好的方法):
String structureId = article.getStructureId();
long groupId = article.getGroupId();
getName(Locale.US, true);
部分将获取具有美国区域设置的结构名称,或者如果没有美国区域设置,它将返回默认区域设置版本。
这应该对你有用。
关于java - 通过 JournalStructureLocalServiceUtil Liferay 获取结构名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12359124/