Liferay7开发文档_3.4.2定义组件METADATA PROPERTIES

当用户向页面添加应用程序时,从类别显示列表中选择应用。

显示categories.png

图1:用户从类别显示列表中选择应用程序。

Portlet的显示类别定义在组件类的metadata property。由于留言portlet允许用户相互通信,因此将其添加到Social类别。只允许一个留言板portlet添加到页面,因此还要将其定义为不可实例化的portlet。这种portlet只能在页面或站点上显示一次,具体取决于其范围。

打开GuestbookPortlet该类并修改组件类metadata properties以完成配置:

@Component(
    immediate = true,
    property = {
        "com.liferay.portlet.display-category=category.social",
        "com.liferay.portlet.instanceable=false",
        "com.liferay.portlet.scopeable=true",
        "javax.portlet.display-name=Guestbook",
        "javax.portlet.expiration-cache=0",
        "javax.portlet.init-param.template-path=/",
        "javax.portlet.init-param.view-template=/guestbookwebportlet/view.jsp",
        "javax.portlet.resource-bundle=content.Language",
        "javax.portlet.security-role-ref=power-user,user",
        "javax.portlet.supports.mime-type=text/html"
    },
    service = Portlet.class
)

com.liferay.portlet.display-category=category.social属性将Guestbook portlet的显示类别设置为Social。该com.liferay.portlet.instanceable=false属性指定“留言”Portlet不可实例化,因此只能将一个Portlet实例添加到页面中。在属性中javax.portlet.init-param.view-template,还将主要位置调整为view.jsp新的位置/guestbookwebportlet

由于编辑了Portlet的元数据,因此必须先移除portlet并将其重新添加到页面,然后才能继续:

  1. Go to localhost:8080 in your web browser.
  2. Sign in to your administrative account.
  3. The Guestbook portlet now shows an error on the page. Click its portlet menu (at the top-right of the portlet), then select Remove and click OK to confirm.
  4. Open the Add menu and select Applications.
  5. Open the Social category and drag and drop the Guestbook application onto the page.

现在,留言簿portlet出现在适当的类别中。

猜你喜欢

转载自blog.csdn.net/qmkemail/article/details/80170364