使用PortletKeys在一个地方管理重要的东西,比如如portlet名称或其他可重复使用的常量。这样,如果需要更改portlet的名称,可以在一个地方完成,然后在需要它的每个类中引用。Keys必须首先被组件属性引用,然后被类引用。
按照以下步骤创建应用程序PortletKeys:
- In your
guestbook-webmodule, open theGuestbookPortletclass and update the component class metadata properties by adding one new property:"javax.portlet.name=" + GuestbookPortletKeys.GUESTBOOK,Note that you need the trailing comma if you’ve added the property to the middle of the list. If you’ve added it to the end of the last, leave it off.
- Save
GuestbookPortlet. It now shows an error because you haven’t added the key to the class. - Open the
com.liferay.docs.guestbook.constantspackage. - Open
GuestbookPortletKeysand create a public, static, final String calledGUESTBOOKwith a value ofcom_liferay_docs_guestbook_portlet_GuestbookPortlet:public static final String GUESTBOOK = "com_liferay_docs_guestbook_portlet_GuestbookPortlet"; - Save the file.
现在GuestbookPortlet的错误已经消失,应用程序可以重新部署。
接下来,将应用程序与使用Service Builder生成的新后端集成。
本文介绍如何通过PortletKeys管理portlet名称和其他重要常量,确保在需要更改portlet名称时只需在一个地方进行更新。此外,还介绍了如何集成使用ServiceBuilder生成的新后端。

被折叠的 条评论
为什么被折叠?



