【问题标题】:Portlet preferences scope in a Liferay configuration pageLiferay 配置页面中的 Portlet 首选项范围
【发布时间】:2014-05-22 20:19:03
【问题描述】:

我开发了一个 Liferay portlet,它具有每个布局唯一的首选项:首选项特定于每个 portlet 窗口,用户可以通过“首选项”选项(编辑模式)修改它们。

在 liferay-portlet.xml 中:

<preferences-unique-per-layout>true</preferences-unique-per-layout>

但是我想添加一个配置页面,以管理应该在所有 portlet 窗口之间共享的全局参数。目前这些参数在portlet.xml中作为“init-param”处理,但不是很方便,管理员用户应该可以通过门户用户界面更改这些参数。

我按照here 描述的方法创建了一个这样的页面,它适用于当前的 portlet 窗口,但不共享首选项。是否可以为某些偏好使用特定范围?这个other wiki 使用了一个指定“uniquePerLayout”和“uniquePerGroup”的方法,但我在 5.2.3 到 6.2 的 API 中没有找到这个方法

public static PortletPreferences getPortletSetup(
      ActionRequest req, 
      String portletId, 
      boolean uniquePerLayout,
      boolean uniquePerGroup)

请有人就这个问题给我启发?

谢谢!

【问题讨论】:

    标签: scope liferay portlet preference


    【解决方案1】:

    在6.2中,有getPortletSetup方法接受布局和分组,

    PortletPreferencesFactoryUtil.getPortletSetup(scopeGroupId, layout, portletId, defaultPreferences)。

    您可以从 themeDisplay 获取 scopeGroupId、布局,如下所示,portletId 和 defaultPreferences 应根据您的要求设置。

        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
        Layout layout = LayoutLocalServiceUtil.getLayout(themeDisplay.getPlid());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-09
      • 1970-01-01
      相关资源
      最近更新 更多