Liferay7开发文档_3.4.3创建PORTLET KEYS

使用PortletKeys在一个地方管理重要的东西,比如如portlet名称或其他可重复使用的常量。这样,如果需要更改portlet的名称,可以在一个地方完成,然后在需要它的每个类中引用。Keys必须首先被组件属性引用,然后被类引用。

按照以下步骤创建应用程序PortletKeys

  1. In your guestbook-web module, open the GuestbookPortlet class 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.

  2. Save GuestbookPortlet. It now shows an error because you haven’t added the key to the class.
  3. Open the com.liferay.docs.guestbook.constants package.
  4. Open GuestbookPortletKeys and create a public, static, final String called GUESTBOOK with a value of com_liferay_docs_guestbook_portlet_GuestbookPortlet:
    public static final String GUESTBOOK =
             "com_liferay_docs_guestbook_portlet_GuestbookPortlet";
    
  5. Save the file.

现在GuestbookPortlet的错误已经消失,应用程序可以重新部署。

接下来,将应用程序与使用Service Builder生成的新后端集成。

猜你喜欢

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