Added a controller, that lists the pages, the user is an adminitrator of
[examples/facebook-app] / src / main / java / de / juplo / yourshouter / PagesController.java
diff --git a/src/main/java/de/juplo/yourshouter/PagesController.java b/src/main/java/de/juplo/yourshouter/PagesController.java
new file mode 100644 (file)
index 0000000..f7091fb
--- /dev/null
@@ -0,0 +1,39 @@
+package de.juplo.yourshouter;
+
+import javax.inject.Inject;
+import org.springframework.social.facebook.api.Account;
+
+import org.springframework.social.facebook.api.Facebook;
+import org.springframework.social.facebook.api.PagedList;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+
+/**
+ * Controller, that handles requests to the root of the application.
+ *
+ * @author Kai Moritz
+ */
+@Controller
+public class PagesController
+{
+  private final Facebook facebook;
+
+
+  @Inject
+  public PagesController(Facebook facebook)
+  {
+    this.facebook = facebook;
+  }
+
+
+  @RequestMapping(value = "/pages.html", method = RequestMethod.GET)
+  public String list(Model model)
+  {
+    PagedList<Account> accounts = facebook.pageOperations().getAccounts();
+    model.addAttribute("accounts", accounts);
+    return "pages";
+  }
+}