private void postActivityToSpace(
      UIComponent source, WebuiRequestContext requestContext, Map<String, String> activityParams)
      throws Exception {
    final UIComposer uiComposer = (UIComposer) source;
    ActivityManager activityManager = uiComposer.getApplicationComponent(ActivityManager.class);
    IdentityManager identityManager = uiComposer.getApplicationComponent(IdentityManager.class);

    SpaceService spaceSrv = uiComposer.getApplicationComponent(SpaceService.class);
    Space space = spaceSrv.getSpaceByUrl(SpaceUtils.getSpaceUrlByContext());

    Identity spaceIdentity =
        identityManager.getOrCreateIdentity(
            SpaceIdentityProvider.NAME, space.getPrettyName(), false);
    String remoteUser = requestContext.getRemoteUser();
    ExoSocialActivity activity =
        saveActivity(activityParams, activityManager, identityManager, spaceIdentity, remoteUser);

    UISpaceActivitiesDisplay uiDisplaySpaceActivities =
        (UISpaceActivitiesDisplay) getActivityDisplay();
    UIActivitiesContainer activitiesContainer =
        uiDisplaySpaceActivities.getActivitiesLoader().getActivitiesContainer();
    activitiesContainer.addActivity(activity);
    requestContext.addUIComponentToUpdateByAjax(activitiesContainer);
    requestContext.addUIComponentToUpdateByAjax(uiComposer);
  }
 protected boolean hasActivities() {
   UIActivitiesLoader uiActivitiesLoader = getChild(UIActivitiesLoader.class);
   UIActivitiesContainer activitiesContainer =
       uiActivitiesLoader.getChild(UIActivitiesContainer.class);
   return activitiesContainer.getChildren().size() > 0;
 }