When the user adds an application to the page, select the 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 GuestbookPortlet
the 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.social
The property sets the Guestbook portlet's display category to Social . This com.liferay.portlet.instanceable=false
property 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.jsp
new position /guestbookwebportlet
.
Since the portlet's metadata was edited, the portlet must be removed and re-added to the page before continuing:
- Go to
localhost:8080
in your web browser. - Sign in to your administrative account.
- 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.
- Open the Add menu and select Applications.
- Open the Social category and drag and drop the Guestbook application onto the page.
The Guestbook portlet now appears in the appropriate category.