Displaying Messages and Errors
Step 3 of 3
Any messages the user should see are now stored in either
SessionErrors. Next, you’ll make these messages appear in your JSPs.
guestbookwebportlet/view.jsp. Add the following block of success messages to the top of the file, just below the
<liferay-ui:success key="entryAdded" message="entry-added" /> <liferay-ui:success key="entryDeleted" message="entry-deleted" />
This tag accesses what’s stored in
SessionMessages. It has two attributes. The first is the
SessionMessageskey that you provided in the
GuestbookPortlet.javaclass’s add and delete methods. The second looks up the specified key in the
Language.propertiesfile. You could have specified a hard-coded message here, but it’s far better to provide a localized key.
guestbookadminportlet/view.jsp. Add the following block of success messages in the same spot below the include:
<liferay-ui:success key="guestbookAdded" message="guestbook-added" /> <liferay-ui:success key="guestbookUpdated" message="guestbook-updated" /> <liferay-ui:success key="guestbookDeleted" message="guestbook-deleted" />
Congratulations! You’ve added useful feedback for operations in your application.
Your application is shaping up, but it is missing another important feature: permissions. Next, you’ll add permission checking for your guestbooks and entries.