DEV Community

Discussion on: Edit Item in Intellij IDEA

Collapse
 
arotto8719 profile image
arotto8719

@RequestMapping(value="edit/{postId}", method = RequestMethod.GET)
public String displayEditForm(Model model, @PathVariable int postId, Error error){
Artifact thePost = artifactRepository.findById(postId).get();
artifactRepository.save(thePost);
model.addAttribute("thePost", thePost);
return "edit";
}

@RequestMapping(value="edit/{post_id}", method=RequestMethod.POST)
public String processEditForm(@RequestParam(value="edit/{post_id}") @PathVariable int post_id, @RequestParam(value="name") String name, @RequestParam(value="location") String location, @RequestParam(value="description") String description, Model model) {
    Artifact thePost = artifactRepository.findById(post_id).get();
    thePost.setName(name);
    thePost.setLocation(location);
    thePost.setDescription(description);
    artifactRepository.save(thePost);
    return "index";
}

This is the problem area. I need exact words and descriptions on what it's supposed to look like.