【问题标题】:Use of Expando in Liferay在 Liferay 中使用 Expando
【发布时间】:2016-02-09 23:16:52
【问题描述】:

我在 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);

【问题讨论】:

    标签: liferay liferay-6


    【解决方案1】:

    您可以简单地从组对象中获取它。 从 themeDisplay 对象中获取站点组,例如 themeDisplay.getSiteGroup()

    您可以从下面的代码中获取自定义属性值。

    Group siteGroup=themeDisplay.getSiteGroup();
    String value =(String)siteGroup.getExpandoBridge().getAttribute("custom-field-name");
    

    HTH

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-01
      相关资源
      最近更新 更多