Blame view

src/main/java/fr/plil/sio/web/mvc/ViewUsersController.java 1.04 KB
aa193b2b   Julien Iguchi-Cartigny   First version
1
2
  package fr.plil.sio.web.mvc;
  
aa193b2b   Julien Iguchi-Cartigny   First version
3
4
5
6
7
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
2070653e   Julien Iguchi-Cartigny   Switching to spri...
8
9
10
  import javax.annotation.Resource;
  import java.util.List;
  
aa193b2b   Julien Iguchi-Cartigny   First version
11
12
13
14
  @Controller
  public class ViewUsersController {
  
      @Resource
8efec875   Julien Iguchi-Cartigny   switch to spring ...
15
      private UserRepository userRepository;
aa193b2b   Julien Iguchi-Cartigny   First version
16
17
18
19
20
  
      @Resource
      private UserSession userSession;
  
      @ModelAttribute("users")
2070653e   Julien Iguchi-Cartigny   Switching to spri...
21
22
      public List<User> populateUsers() {
          return userRepository.findAll();
aa193b2b   Julien Iguchi-Cartigny   First version
23
24
25
26
27
28
29
30
31
32
33
34
      }
  
      @ModelAttribute("userSession")
      public UserSession populateUser() {
          return userSession;
      }
  
      @RequestMapping(value={"/"},method=RequestMethod.GET)
      public String getViewUsers() {
          return "viewUsers";
      }
  
8efec875   Julien Iguchi-Cartigny   switch to spring ...
35
36
      public void setUserRepository(UserRepository userRepository) {
          this.userRepository = userRepository;
aa193b2b   Julien Iguchi-Cartigny   First version
37
38
39
40
41
42
      }
  
      public void setUserSession(UserSession userSession) {
          this.userSession = userSession;
      }
  }