Ejemplo n.º 1
0
 @RequestMapping(
     value = RequestTarget.STORY_UPDATE + "/" + RequestConstants.ID,
     method = RequestMethod.GET)
 public String update(@PathVariable String id, ModelMap model) {
   StoryForm data = new StoryForm();
   data.loadFromStory(projectService.loadStoryWithProject(id));
   model.addAttribute("story", data);
   return RequestTarget.STORY_UPDATE;
 }
Ejemplo n.º 2
0
  @RequestMapping(RequestTarget.STORY_CREATE + "/" + RequestConstants.PROJECT_ID)
  public String create(@PathVariable String projectId, ModelMap model) {
    Story story = new Story();
    story.setProject(projectService.loadProject(projectId));

    StoryForm form = new StoryForm();
    form.loadFromStory(story);

    model.addAttribute(ModelConstants.STORY, form);
    return RequestTarget.STORY_CREATE;
  }
Ejemplo n.º 3
0
  @RequestMapping(
      value = RequestTarget.STORY_CREATE,
      method = {RequestMethod.POST})
  public String create(
      @ModelAttribute(ModelConstants.STORY) @Valid StoryForm form, BindingResult result) {
    if (result.hasErrors()) {
      return RequestTarget.STORY_CREATE;
    }

    Story story = form.asStory();
    projectService.createStory(story);
    return "redirect:" + RequestTarget.PROJECT_SHOW + "/" + story.getProject().getId();
  }