Creating Portlet Keys

Building the Web Front-End

Step 3 of 11

PortletKeys manage important things like the portlet name or other repeatable, commonly used variables in one place. This way, if you must change the portlet’s name, you can do it in one place and then reference it in every class that needs it. Keys are created in a PortletKeys class and then referenced in a component property.

Follow these steps to create your application’s PortletKeys:

  1. Open the package.

  2. Open GuestbookPortletKeys and make sure there’s a public, static, final String called GUESTBOOK with a value of com_liferay_docs_guestbook_portlet_GuestbookPortlet:

    public static final String GUESTBOOK =
  3. Save the file.

  4. In your guestbook-web module, open the GuestbookPortlet class and update the component class metadata properties by adding one new property:

    "" + 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 (but add a trailing comma to the prior property!).

  5. Save GuestbookPortlet.

Nice job!

Next, you’ll integrate your application with the back-end you generated with Service Builder.

« Defining the Component Metadata PropertiesIntegrating the Back-end »
Was this article helpful?
2 out of 2 found this helpful