Added a second page to proof, that the connection is persisted
[examples/facebook-app] / src / main / java / de / juplo / yourshouter / ProfileController.java
diff --git a/src/main/java/de/juplo/yourshouter/ProfileController.java b/src/main/java/de/juplo/yourshouter/ProfileController.java
new file mode 100644 (file)
index 0000000..35cadc8
--- /dev/null
@@ -0,0 +1,36 @@
+package de.juplo.yourshouter;
+
+import javax.inject.Inject;
+
+import org.springframework.social.facebook.api.Facebook;
+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 ProfileController
+{
+  private final Facebook facebook;
+
+
+  @Inject
+  public ProfileController(Facebook facebook)
+  {
+    this.facebook = facebook;
+  }
+
+
+  @RequestMapping(value = "/profile.html", method = RequestMethod.GET)
+  public String show(Model model)
+  {
+    model.addAttribute("profile", facebook.userOperations().getUserProfile());
+    return "profile";
+  }
+}