Posting status from the Visualforce page

If you update your status from the Visualforce page, your status gets updated in real time. This is shown in the following screenshot:

Posting status from the Visualforce page

The following is the code for the Visualforce pages:

<apex:outputPanel id="recent">
  <apex:dataList value="{!recentTextUpdates}" var="update">
    <apex:outputText value="{!update.body}"/>
  </apex:dataList>
</apex:outputPanel>

Here we are using an output panel with id= "recent" that will show all the recent status updates. The dataList attribute has a value attribute that iterates over the list (here we have recenttextupdates enclosed in output text that shows the updates).

The following is the controller code:

public List<FeedItem> getRecentTextUpdates() 
  {
    List <feeditem> aNewsFeed = [SELECT Type, CreatedDate,CreatedBy.name, Body FROM FeedItem WHERE Type='TextPost'ORDER BY CreatedDate DESC LIMIT 10];
   return aNewsFeed;
  }

The list of type feeditem is named as recentTextUpdates, and we are using its getter to get values so that it is getrecentTextUpdates. The list in this getter is of type feedItem named aNews feed, and it selects all 10 recent posts of the textpost type in the descending order.

In the preceding code, the output panel is used with the data list to display status (current and old). In Chatter, posts are stored in the FeedItem object; to get the textpost type, you can use type = "TextPost".

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.138.138