我已经为Liferay中的站点资源创建了一个自定义字段,这是一个带有默认值的简单文本值。我想在我的自定义portlet中显示它。
我已经读到,我们将使用ExpandoBridge API获取自定义字段值,但我完全搞不懂。我们可以使用为Expando提供的LocalServiceUtil类来获取值吗?
任何帮助都将不胜感激。我对Liferay很陌生。
long classNameId = ClassNameLocalServiceUtil.getClassNameId(Sites.class.getName());
ThemeDisplay themeDisplay =(ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
String columnName = "Org. Tag Line";// key
String tableName = "CUSTOM_FIELDS";
long siteId = themeDisplay.getSiteGroupId();// userId=classPK
ExpandoValue expandoObiect=ExpandoValueLocalServiceUtil.getValue(themeDisplay.getCompanyId(), classNameId, tableName, columnName, userId);
ExpandoValue expandoObiect=ExpandoValueLocalServiceUtil.getValue(companyId, className, tableName, columnName, classPK)
String value=expandoObiect.getData();
renderRequest.setAttribute("tagLine", value);
System.out.println("Field value==>"+value);发布于 2016-02-09 15:16:52
您可以简单地从组对象中获取它。从themeDisplay对象(如themeDisplay.getSiteGroup() )获取站点组
您可以通过下面的代码从组中获得自定义属性值。
Group siteGroup=themeDisplay.getSiteGroup();
String value =(String)siteGroup.getExpandoBridge().getAttribute("custom-field-name");HTH
https://stackoverflow.com/questions/35293785
复制相似问题