0

我正在处理我在 Internet 上找到的一些代码 - 我只参加过 ADM 201 课程。

我正在做的是尝试从帖子中提取信息,然后将其放入 VF 页面。我知道我可以使用 chatter:feed,但这是获取所有信息和功能,而我只需要正文、海报名称和图片(不是必需的)。

到目前为止我所拥有的:

顶点类:

    public class Test_3 {        //Class is 
public ConnectApi.FeedElementPage feedElementPage{get;set;}
public Test_3() {
    feedElementPage =    ConnectApi.ChatterFeeds.getFeedElementsFromFeed('0F958000000TWvL',   ConnectApi.FeedType.Record, 'showInternalOnly');
    }
    }

VF 页面:

<apex:page controller="Test_5">
   <div class="posts">
      <div class="row">
      <div class="col-md-6">
        <apex:repeat value="{!feed.elements}" var="feedElement">
            <div class="media">
                <a class="pull-left" href="{!feedElement.parent.id}">
                <img class="media-object" src="{!feedElement.photoUrl}" alt="{!feedElement.actor.name}"/>
                    </a>
                    <div class="media-body">
                        <h4 class="media-heading">{!feedItem.actor.name}</h4>
                        // This creates a heading from the posts that is the poster's name
                        {!feedElement.body.text}
                        // This is the body of the post
                        </div>
                    </div>
       </apex:repeat>
      </div>
 </div>
</div>

 <footer>
    <p>&copy; Operations Updates - Please refresh your browser for the latest</p>
 </footer>
</apex:page>

目前的问题:

  • !feedElement.parent.id
  • !feedItem.actor.name
  • “错误:未知属性‘ConnectApi.Feed.elements’”

无论如何,我无法解决这个问题。我一直在努力做这个可爱的 5 个小时。

任何帮助将非常感激。

代码是从这里修改的,然后我尝试将其更新为 Items 中的 Elements。

谢谢

4

1 回答 1

0

在您的 Apex 类中,该变量称为“feedElementPage”,但在 Visualforce 页面中,它显示为“feed”。请更新feedElementPagefeedApex 类或更新repeat value="{!feed.elements}"repeat value="{!feedElementPage.elements}"

另外,我认为您应该使用FeedItem而不是FeedElement。请查看文档,如果您有任何其他问题,请告诉我。

于 2016-03-31T22:11:27.527 回答