0

Currently i am trying get chatter feed in visualforce page. I only want the feed which has a query string. But i want all the recent comments for the post. I couldn't find a visualforce tag to get the filtered feed. So i wrote visualforce page.

Problem: my code is only getting the comments which have the query string. where as i want all the comments related to the post which has the query string.

controller:

feedItemPage = ConnectApi.ChatterFeeds.searchFeedItems(null,'Google',ConnectApi.FeedSortOrder.CreatedDateDesc);

page:

<apex:page showheader="true" sidebar="false" controller="Hoov_GCSContentController"  standardStyleSheets="false"  cache="true"  docType="html-5.0">
  <apex:pageBlock >
    <div class= "container">
      <apex:pageBlockSection showHeader="true" title="Chatter" columns="1">
        <apex:repeat value="{!feedItemPage.items}" var="feedItems">
          <apex:pageBlockSection showHeader="false" title="feed" columns="1">
            <div class="media">
              <apex:outputLink value="/{!feedItems.parent.Id}" >
                <apex:image value="{!feedItems.photoUrl}" alt="{!feedItems.actor.name}"/>
              </apex:outputLink>
              <div class = "media-body">
                <apex:repeat value="{!feedItems.body.messageSegments}" var="segment">
                  <h4 class = "media-heading">{!feedItems.actor.name}</h4>
                  <apex:outputPanel layout="none" rendered="{!segment.type == TextSegmentType}">
                                    {!segment.text}
                                    </apex:outputPanel>
                  <apex:outputPanel layout="none" rendered="{!segment.type == MentionSegmentType}">
                    <a href="/{segment['record'.id]}">@{!segment['record'].name}</a>
                  </apex:outputPanel>
                </apex:repeat>
                <apex:pageBlockSection showHeader="true" title="Comment" columns="1">
                  <!--comments.comments-->
                  <apex:repeat value="{!feedItems.Comments.comments}" var="comment">
                    <!-- <apex:outputPanel layout="none" rendered="{!Comment.type == TextCommentType}">
                                    {!Comment.type}
                                    </apex:outputPanel>-->
                    <div class="media">
                      <apex:pageBlockSectionItem >
                        <apex:outputLink value="/{!comment.parent.Id}" >
                          <apex:image value="{!comment.user.photo.smallPhotoUrl}" alt="{!comment.user.firstname}"/>
                        </apex:outputLink>
                        <apex:pageBlockSection showHeader="false" title="Comment" columns="1">
                          <div class = "media-body">
                            <h4 class = "media-heading">{!comment.user.firstname} {!comment.user.lastname}</h4>
                            <apex:repeat value="{!comment.body.messageSegments}" var="segment">
                              <apex:outputPanel layout="none" rendered="{!segment.type == TextSegmentType}">
                                    {!segment.text}
                                    </apex:outputPanel>
                              <apex:outputPanel layout="none" rendered="{!segment.type == MentionSegmentType}">
                                <a href="/{segment['record'.id]}">@{!segment['record'].name}</a>
                              </apex:outputPanel>
                            </apex:repeat>
                          </div>
                        </apex:pageBlockSection>
                      </apex:pageBlockSectionItem>
                    </div>
                  </apex:repeat>
                </apex:pageBlockSection>
              </div></div>
            </apex:pageblocksection>
          </apex:repeat>
        </apex:pageblocksection>
      </div>
    </apex:pageBlock>
  </apex:page>
1
  • I want to know if we can only search the post and get all the comments
    – Farscape
    Commented Aug 20, 2015 at 17:42

1 Answer 1

1

You'd have to make another call in your controller to get the comments for each feed item returned from ConnectApi.ChatterFeeds.searchFeedItems(). There isn't a way to request the entire list of comments from a feed search request.

You'd have to call one of the ConnectApi.ChatterFeeds.getCommentsForFeedElement() methods.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .