Ignore:
Timestamp:
03/05/23 17:35:54 (16 months ago)
Author:
SazdovaEkaterina <sazdovaekaterina@…>
Branches:
main
Children:
8b7dd7f
Parents:
9358bff
Message:

use model instead of session

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java

    r9358bff r5f53114  
    7777
    7878    @GetMapping("/adoption-posts")
    79     public String getAdoptionPosts(Model model, HttpServletRequest request){
     79    public String getAdoptionPosts(Model model){
    8080
    8181        List<Post> posts = this.postService.findAll();
    8282        List<Pet> pets = this.petService.listpets();
    83         //model.addAttribute("posts", posts);
    84         //model.addAttribute("pets",pets);
    85         request.getSession().setAttribute("posts",posts);//temp
    86         request.getSession().setAttribute("pets",pets);//temp
     83        model.addAttribute("posts", posts);
     84        model.addAttribute("pets",pets);
    8785
    8886        return "list-posts-adoption";
     
    9088
    9189    @GetMapping("/pet-details-{id}")
    92     public String getPostDetails(@PathVariable Integer id, Model model, HttpServletRequest request){
     90    public String getPostDetails(@PathVariable Integer id,
     91                                 Model model){
    9392
    9493        Post post = this.postService.findById(id).get();
    9594        Pet pet = this.petService.findById(post.getPetId());
    9695
    97         //model.addAttribute("pet", pet);
    98         //model.addAttribute("post", post);
    99         request.getSession().setAttribute("post", post);//temp
    100         request.getSession().setAttribute("pet", pet);//temp
    101 
    102         if(pet.getAdoptionId() != null){
    103             request.getSession().setAttribute("disableAdoption", true);
    104         } else{
    105             request.getSession().setAttribute("disableAdoption", false);
    106         }
     96        model.addAttribute("pet", pet);
     97        model.addAttribute("post", post);
    10798
    10899        return "pet-details";
Note: See TracChangeset for help on using the changeset viewer.