Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Use the 'NotificationLifecycleController.doEvents' preference to turn on event processing for a portlet definition.

Example NotificationResult Response Code

Use code like the following -- within another portlet -- to respond to NotificationQuery events and feed items to the NotificationPortlet.

Spring Portlet MVC Controller
    @EventMapping(NOTIFICATION_QUERY_QNAME_STRING)
    public void echo(final EventRequest req, final EventResponse res) {
        
        final NotificationQuery query = (NotificationQuery) req.getEvent().getValue();
        
        final NotificationEntry entry = new NotificationEntry();
        entry.setSource("foo");
        entry.setTitle("OMG WOOT!");
        final NotificationCategory category = new NotificationCategory();
        category.setTitle("MONKEY");
        category.setEntries(Arrays.asList(new NotificationEntry[] { entry }));
        final NotificationResponse response = new NotificationResponse();
        response.setCategories(Arrays.asList(new NotificationCategory[] { category }));
        final NotificationResult result = new NotificationResult();
        result.setQueryWindowId(query.getQueryWindowId());
        result.setResultWindowId(req.getWindowID());
        result.setNotificationResponse(response);
        
        res.setEvent(NotificationLifecycleController.NOTIFICATION_RESULT_QNAME, result);
    }

  • No labels