Blame view

src/main/java/fr/plil/sio/web/mvc/ViewUsersController.java 799 Bytes
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
  
aa193b2b   Julien Iguchi-Cartigny   First version
17
      @ModelAttribute("users")
2070653e   Julien Iguchi-Cartigny   Switching to spri...
18
19
      public List<User> populateUsers() {
          return userRepository.findAll();
aa193b2b   Julien Iguchi-Cartigny   First version
20
21
      }
  
aa193b2b   Julien Iguchi-Cartigny   First version
22
23
24
25
26
      @RequestMapping(value={"/"},method=RequestMethod.GET)
      public String getViewUsers() {
          return "viewUsers";
      }
  
8efec875   Julien Iguchi-Cartigny   switch to spring ...
27
28
      public void setUserRepository(UserRepository userRepository) {
          this.userRepository = userRepository;
aa193b2b   Julien Iguchi-Cartigny   First version
29
      }
aa193b2b   Julien Iguchi-Cartigny   First version
30
  }