Liferay7 Development Document _3.4.2 Define Components METADATA PROPERTIES

When the user adds an application to the page, select the application from the category display list.

showcategories.png

Figure 1: The user selects an application from the category display list.

The display category of the portlet is defined in the metadata property of the component class. Since the Messaging portlet allows users to communicate with each other, it was added to the Social category. Only one message board portlet is allowed to be added to a page, so also define it as a non-instantiable portlet. Such a portlet can only be displayed once on a page or site, depending on its scope.

Open GuestbookPortletthe class and modify the component class metadata properties to complete the configuration:

@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.socialThe property sets the Guestbook portlet's display category to Social . This com.liferay.portlet.instanceable=falseproperty specifies that the "message" portlet is not instantiable, so only one portlet instance can be added to the page. In the properties javax.portlet.init-param.view-template, also adjust the main position to the view.jspnew position /guestbookwebportlet.

Since the portlet's metadata was edited, the portlet must be removed and re-added to the page before continuing:

  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.

The Guestbook portlet now appears in the appropriate category.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325190645&siteId=291194637