Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-38598

As a developer I wish to create quick actions to display with my notifications using the notifications framework

    Details

      Description

      It would be great if we could create quick actions that a user would be able to do right from the notifications instead of having to click a link first. For example, if you are sent a friend quest, it would be great to accept or decline right from the notification.

      Developer can follow the sample code below to create Confirm and Ignore Button. Use the code in the getBody () method in NotificationHandler for your portlet.

      LiferayPortletResponse liferayPortletResponse =
      serviceContext.getLiferayPortletResponse();

      PortletURL confirmURL = liferayPortletResponse.createActionURL(
      PortletKeys.CONTACTS_CENTER);

      confirmURL.setParameter(
      ActionRequest.ACTION_NAME, "updateSocialRequest");
      confirmURL.setParameter("redirect", serviceContext.getLayoutFullURL());
      confirmURL.setParameter(
      "socialRequestId", String.valueOf(socialRequestId));
      confirmURL.setParameter(
      "status", String.valueOf(SocialRequestConstants.STATUS_CONFIRM));
      confirmURL.setParameter(
      "userNotificationEventId",
      String.valueOf(userNotificationEvent.getUserNotificationEventId()));
      confirmURL.setWindowState(WindowState.NORMAL);

      PortletURL ignoreURL = liferayPortletResponse.createActionURL(
      PortletKeys.CONTACTS_CENTER);

      ignoreURL.setParameter(
      ActionRequest.ACTION_NAME, "updateSocialRequest");
      ignoreURL.setParameter("redirect", serviceContext.getLayoutFullURL());
      ignoreURL.setParameter(
      "socialRequestId", String.valueOf(socialRequestId));
      ignoreURL.setParameter(
      "status", String.valueOf(SocialRequestConstants.STATUS_IGNORE));
      ignoreURL.setParameter(
      "userNotificationEventId",
      String.valueOf(userNotificationEvent.getUserNotificationEventId()));
      ignoreURL.setWindowState(WindowState.NORMAL);

      return StringUtil.replace(
      getBodyTemplate(),
      new String[]

      { "[$CONFIRM$]", "[$CONFIRM_URL$]", "[$IGNORE$]", "[$IGNORE_URL$]", "[$TITLE$]" }

      ,
      new String[]

      { serviceContext.translate("confirm"), confirmURL.toString(), serviceContext.translate("ignore"), ignoreURL.toString(), title }

      );

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                support-lep@liferay.com SE Support
                Reporter:
                david.truong David Truong
                Recent user:
                Shalaka Tendulkar
                Participants of an Issue:
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Packages

                  Version Package