Example usage for org.springframework.web.bind.support SessionStatus setComplete

List of usage examples for org.springframework.web.bind.support SessionStatus setComplete

Introduction

In this page you can find the example usage for org.springframework.web.bind.support SessionStatus setComplete.

Prototype

void setComplete();

Source Link

Document

Mark the current handler's session processing as complete, allowing for cleanup of session attributes.

Usage

From source file:org.hydroponics.web.controller.EditArduino.java

@RequestMapping(method = RequestMethod.POST)
public String processSubmit(@ModelAttribute ControllerEditBean controllerEditBean, BindingResult result,
        SessionStatus status, String formAction) {
    logger.info(new StringBuffer("process submit:").append(controllerEditBean).append("\n\tBindResult:")
            .append(result).append("\n\tSessionState:").append(status).append("\n\tFormAction:")
            .append(formAction).toString());

    if (formAction != null && formAction.equals(Constants.ACTION_SUBMIT)) {
        controllerValidator.validate(controllerEditBean, result);
        if (result.hasErrors()) {
            return "controller";
        } else {//from w  w  w  .j  a v  a2s.  co  m
            //TODO hydroponicsClientHandler.saveControllerConfig(controllerEditBean);
            status.setComplete();
            return Constants.REDIRECT_MAIN;
        }
    } else if (formAction != null && formAction.equals(Constants.ACTION_CANCEL)) {
        status.setComplete();
        return Constants.REDIRECT_MAIN;
    } else {
        throw new RuntimeException("unknown form action:" + formAction);
    }
}

From source file:csns.web.controller.ForumTopicControllerS.java

@RequestMapping(value = "/department/{dept}/forum/topic/edit", method = RequestMethod.POST)
public String edit(@ModelAttribute Post post, @PathVariable String dept,
        @RequestParam(value = "file", required = false) MultipartFile[] uploadedFiles, BindingResult result,
        SessionStatus sessionStatus) {
    messageValidator.validate(post, result);
    if (result.hasErrors())
        return "forum/topic/edit";

    User user = SecurityUtils.getUser();
    post.setEditedBy(user);//from   ww w.ja v  a 2s . co  m
    post.setEditDate(new Date());
    if (uploadedFiles != null)
        post.getAttachments().addAll(fileIO.save(uploadedFiles, user, true));
    post = postDao.savePost(post);

    logger.info(user.getUsername() + " edited post " + post.getId());

    sessionStatus.setComplete();
    return "redirect:/department/" + dept + "/forum/topic/view?id=" + post.getTopic().getId();
}

From source file:csns.web.controller.SurveyControllerS.java

@RequestMapping(value = "/department/{dept}/survey/addQuestion", method = RequestMethod.POST)
public String addQuestion(@ModelAttribute("question") Question question, @RequestParam Long surveyId,
        @RequestParam int sectionIndex, BindingResult result, SessionStatus sessionStatus) {
    questionValidator.validate(question, result);
    if (result.hasErrors())
        return "survey/addQuestion";

    Survey survey = surveyDao.getSurvey(surveyId);
    if (!survey.isPublished()) {
        survey.getQuestionSheet().getSections().get(sectionIndex).getQuestions().add(question);
        surveyDao.saveSurvey(survey);//ww  w .  j  a  va  2 s .c  o  m

        logger.info(SecurityUtils.getUser().getUsername() + " added a question to survey " + surveyId);
    }

    sessionStatus.setComplete();
    return "redirect:editQuestionSheet?surveyId=" + surveyId + "&sectionIndex=" + sectionIndex;
}

From source file:org.sloth.web.user.EditUserController.java

/**
 * Handles all {@code POST} requests and saves the changes made to the
 * {@code User}.//from www . ja  v a2  s . c  o m
 */
@RequestMapping(method = POST)
public String processSubmit(HttpSession session, HttpServletResponse response,
        @ModelAttribute(USER_ATTRIBUTE) UserEditFormAction action, BindingResult result, SessionStatus status)
        throws IOException {
    if (isSameId(session, action.getId()) || isAdmin(session)) {
        this.userEditFormValidator.validate(action, result);
        if (result.hasErrors()) {
            return VIEW;
        } else {
            try {
                this.userService.update(action.getMergedUser());
            } catch (Exception e) {
                logger.warn("Unexpected Exception", e);
                return internalErrorView(response);
            } finally {
                status.setComplete();
            }
            if (isSameId(session, action.getId())) {
                return "redirect:/acc";
            } else {
                return "redirect:/u";
            }
        }
    }
    return forbiddenView(response);
}

From source file:org.motechproject.server.omod.web.controller.CommunityController.java

@RequestMapping(value = "/module/motechmodule/community/add.form", method = RequestMethod.POST)
public String submitForm(@ModelAttribute("community") WebCommunity webCommunity, Errors errors,
        ModelMap modelMap, SessionStatus status) {
    MotechService motechService = contextService.getMotechService();

    webCommunityValidator.validate(webCommunity, errors);

    if (errors.hasErrors()) {
        modelMap.addAttribute("community", webCommunity);
        return "/module/motechmodule/addcommunity";
    }//from  w  w  w  . j  av  a2s  .com
    Community community = new Community(webCommunity.getName(),
            motechService.getFacilityById(webCommunity.getFacilityId()));
    contextService.getRegistrarBean().saveCommunity(community);
    modelMap.addAttribute("successMsg", "Community added");
    status.setComplete();
    return "redirect:/module/motechmodule/community.form";
}

From source file:org.hydroponics.web.controller.AddFertilizer.java

@RequestMapping(method = RequestMethod.POST)
public String processSubmit(@ModelAttribute FertilizerEditBean fertilizerEditBean, BindingResult result,
        SessionStatus status, String formAction) {
    logger.info(new StringBuffer("process submit:").append(fertilizerEditBean).append("\n\tBindResult:")
            .append(result).append("\n\tSessionState:").append(status).append("\n\tFormAction:")
            .append(formAction).toString());

    if (formAction != null && formAction.equals(Constants.ACTION_SUBMIT)) {
        fertilizerValidator.validate(fertilizerEditBean, result);
        if (result.hasErrors()) {
            return Constants.PAGE_ADD_FERTILIZER;
        } else {//from  w  ww  . java 2 s. co  m
            this.hydroponicsDao.saveFertilizer(fertilizerEditBean);
            status.setComplete();
            return Constants.REDIRECT_MAIN;
        }
    } else if (formAction != null && formAction.equals(Constants.ACTION_CANCEL)) {
        status.setComplete();
        return Constants.REDIRECT_MAIN;
    } else {
        throw new RuntimeException("unknown form action:" + formAction);
    }
}

From source file:csns.web.controller.NewsControllerS.java

@RequestMapping(value = "/department/{dept}/news/edit", method = RequestMethod.POST)
public String edit(@ModelAttribute News news, @PathVariable String dept,
        @RequestParam(value = "file", required = false) MultipartFile[] uploadedFiles, BindingResult result,
        SessionStatus sessionStatus) {
    newsValidator.validate(news, result);
    if (result.hasErrors())
        return "news/edit";

    Post post = news.getTopic().getFirstPost();
    User user = SecurityUtils.getUser();
    if (uploadedFiles != null)
        post.getAttachments().addAll(fileIO.save(uploadedFiles, user, true));
    post.setEditedBy(user);/*from  w  ww  .  j  a  v a  2s.c  o  m*/
    post.setEditDate(new Date());
    postDao.savePost(post);
    news = newsDao.saveNews(news);

    logger.info(user.getUsername() + " edited news " + news.getId());

    sessionStatus.setComplete();
    return "redirect:/department/" + dept + "/news/current";
}

From source file:org.motechproject.server.omod.web.controller.CommunityController.java

@RequestMapping(value = "/module/motechmodule/community/editcommunity.form", method = RequestMethod.POST)
public String viewEditForm(@ModelAttribute("community") WebCommunity webCommunity, Errors errors,
        ModelMap modelMap, SessionStatus status) {
    MotechService motechService = contextService.getMotechService();
    webCommunityValidator.validate(webCommunity, errors);

    if (errors.hasErrors()) {
        modelMap.addAttribute("community", webCommunity);
        return "/module/motechmodule/editcommunity";
    }//from   w ww  .  jav  a  2  s .  co  m
    Community community = motechService.getCommunityById(webCommunity.getCommunityId());
    community.setFacility(motechService.getFacilityById(webCommunity.getFacilityId()));
    community.setName(webCommunity.getName());
    contextService.getRegistrarBean().saveCommunity(community);
    status.setComplete();
    return "redirect:/module/motechmodule/community.form";
}

From source file:elekto.results.ResultsController.java

@RequestMapping(value = "/calculate", method = GET)
public ModelAndView main(
        @ModelAttribute(MODEL_ATTRIBUTE_RESULTS_INPUTS) final ResultsInputsForm resultsInputsForm,
        final BindingResult errors, final SessionStatus status) throws IOException {
    final ModelAndView modelAndView = new ModelAndView("calculate");

    new ResultInputsValidator().validate(resultsInputsForm, errors);
    if (errors.hasErrors()) {
        LOGGER.warn("errors: {}", errors);
    }//from ww w.j av a2 s .c  o m
    if (resultsInputsForm.hasCachedElectionsModelData()) {
        final ResultsProvider resultsProvider = this.resultsProviderFactory
                .create(resultsInputsForm.getCachedElectionsModelData());
        modelAndView.addObject("resultsProvider", resultsProvider);

        // TODO with an DAO: resultsProvider.getCerfaDocument().save(outStream);
    }

    status.setComplete();

    return modelAndView;
}

From source file:edu.uchicago.duo.web.DuoEnrollController.java

@RequestMapping(method = RequestMethod.POST, params = "reset")
public String resetform(ModelMap model, @ModelAttribute("DuoPerson") DuoPersonObj duoperson,
        HttpSession session, SessionStatus status) {

    status.setComplete();
    return "redirect:/secure";
}