From 11bd1660100f320d039dbcf9197e98b360b4daa0 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 21 Jan 2016 16:58:46 +0100 Subject: [PATCH] Added a second page to proof, that the connection is persisted --- .../juplo/yourshouter/ProfileController.java | 36 +++++++++++++++++++ src/main/resources/templates/home.html | 1 + src/main/resources/templates/profile.html | 20 +++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/main/java/de/juplo/yourshouter/ProfileController.java create mode 100644 src/main/resources/templates/profile.html diff --git a/src/main/java/de/juplo/yourshouter/ProfileController.java b/src/main/java/de/juplo/yourshouter/ProfileController.java new file mode 100644 index 0000000..35cadc8 --- /dev/null +++ b/src/main/java/de/juplo/yourshouter/ProfileController.java @@ -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"; + } +} diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html index 04d9d8a..b4d0074 100644 --- a/src/main/resources/templates/home.html +++ b/src/main/resources/templates/home.html @@ -7,6 +7,7 @@

Hello, Some User!

diff --git a/src/main/resources/templates/profile.html b/src/main/resources/templates/profile.html new file mode 100644 index 0000000..f0b3dab --- /dev/null +++ b/src/main/resources/templates/profile.html @@ -0,0 +1,20 @@ + + + + Hello Facebook + + +

Back HOME

+
+

Public available profile-data

+ + + -- 2.20.1