Added a controller, that lists the pages, the user is an adminitrator of
[examples/facebook-app] / src / main / java / de / juplo / yourshouter / PagesController.java
1 package de.juplo.yourshouter;
2
3 import javax.inject.Inject;
4 import org.springframework.social.facebook.api.Account;
5
6 import org.springframework.social.facebook.api.Facebook;
7 import org.springframework.social.facebook.api.PagedList;
8 import org.springframework.stereotype.Controller;
9 import org.springframework.ui.Model;
10 import org.springframework.web.bind.annotation.RequestMapping;
11 import org.springframework.web.bind.annotation.RequestMethod;
12
13
14 /**
15  * Controller, that handles requests to the root of the application.
16  *
17  * @author Kai Moritz
18  */
19 @Controller
20 public class PagesController
21 {
22   private final Facebook facebook;
23
24
25   @Inject
26   public PagesController(Facebook facebook)
27   {
28     this.facebook = facebook;
29   }
30
31
32   @RequestMapping(value = "/pages.html", method = RequestMethod.GET)
33   public String list(Model model)
34   {
35     PagedList<Account> accounts = facebook.pageOperations().getAccounts();
36     model.addAttribute("accounts", accounts);
37     return "pages";
38   }
39 }