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.openmrs.module.accounting.web.controller.account.AccountFormController.java

@RequestMapping(method = RequestMethod.POST)
public String onSubmit(@ModelAttribute("accountCommand") AccountCommand command, BindingResult bindingResult,
        Model model, HttpServletRequest request, SessionStatus status) {

    new AccountValidator().validate(command, bindingResult);
    if (bindingResult.hasErrors()) {
        return "/module/accounting/account/form";
    }// w w w  .  j a va  2 s.  co m
    Context.getService(AccountingService.class).saveAccount(command.getAccount(), command.getPeriod());
    // Clean the session attribute after successful submit
    status.setComplete();
    return "redirect:/module/accounting/account.list";
}

From source file:org.openmrs.module.patientflags.web.EditPriorityController.java

/**
 * Processes the form to edit (or add) a Priority
 * //from  www  .j av  a2 s. c  o  m
 * @param priority the priority to add/update
 * @param result
 * @param status
 * @return new ModelAndView
 */
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processSubmit(@ModelAttribute("priority") Priority priority, BindingResult result,
        SessionStatus status) {

    // validate form entries
    validator.validate(priority, result);

    if (result.hasErrors()) {
        return new ModelAndView("/module/patientflags/editPriority");
    }

    // add the new tag
    Context.getService(FlagService.class).savePriority(priority);

    // clears the command object from the session
    status.setComplete();

    // just display the edit page again
    return new ModelAndView("redirect:/module/patientflags/managePriorities.list");
}

From source file:org.openmrs.module.patientflags.web.ManagePatientFlagsProperties.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processSubmit(@ModelAttribute("properties") PatientFlagsProperties properties,
        BindingResult result, SessionStatus status) {

    // validate form entries
    validator.validate(properties, result);

    if (result.hasErrors()) {
        return new ModelAndView("/module/patientflags/managePatientFlagsProperties");
    }//w w w .j a  v  a 2  s . co m

    // save updated properties
    Context.getService(FlagService.class).savePatientFlagsProperties(properties);

    // clears the command object from the session
    status.setComplete();
    return new ModelAndView("/module/patientflags/managePatientFlagsPropertiesSuccess");
}

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

@RequestMapping(value = "/department/{dept}/rubric/create", method = RequestMethod.POST)
public String create(@ModelAttribute Rubric rubric, BindingResult result, SessionStatus sessionStatus) {
    rubricValidator.validate(rubric, result);
    if (result.hasErrors())
        return "rubric/create";

    rubric.setCreator(SecurityUtils.getUser());
    rubric = rubricDao.saveRubric(rubric);

    logger.info(SecurityUtils.getUser().getUsername() + " created rubric " + rubric.getId());

    sessionStatus.setComplete();
    return "redirect:view?id=" + rubric.getId();
}

From source file:eu.scidipes.toolkits.pawebapp.web.UserManagementController.java

@RequestMapping(value = "/add", method = RequestMethod.POST)
public String add(@ModelAttribute("newUser") final User newUser, final BindingResult result,
        final SessionStatus status, final RedirectAttributes redirectAttrs) {

    new UserValidator(userRepo).validate(newUser, result);

    if (result.hasErrors()) {
        LOG.debug("Errors encountered in newUser");
        return "/admin/users";
    }//from w  w  w. j a  v  a  2 s  .co  m

    newUser.setPassword(passwordEncoder.encode(newUser.getNewPassword()));
    userRepo.save(newUser);

    status.setComplete();
    redirectAttrs.addFlashAttribute("msgKey", "users.management.new.success");
    return "redirect:/admin/users";
}

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

@RequestMapping(value = "/user/advisement/edit", method = RequestMethod.POST)
public String edit(@ModelAttribute("record") AdvisementRecord record,
        @RequestParam(value = "file", required = false) MultipartFile[] uploadedFiles,
        SessionStatus sessionStatus) {
    User student = record.getStudent();// w w  w  .j ava  2 s.co  m
    if (uploadedFiles != null)
        record.getAttachments().addAll(fileIO.save(uploadedFiles, student, false));

    record = advisementRecordDao.saveAdvisementRecord(record);

    logger.info(SecurityUtils.getUser().getUsername() + " edited advisment record " + record.getId());

    sessionStatus.setComplete();
    // Advisement is the 5th tab
    return "redirect:/user/view?id=" + student.getId() + "#4";
}

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

@RequestMapping(value = "/department/{dept}/survey/edit", method = RequestMethod.POST)
public String edit(@ModelAttribute Survey survey, HttpServletRequest request, BindingResult result,
        SessionStatus sessionStatus) {
    surveyValidator.validate(survey, result);
    if (result.hasErrors())
        return "survey/edit";

    survey = surveyDao.saveSurvey(survey);

    logger.info(SecurityUtils.getUser().getUsername() + " edited survey " + survey.getId());

    sessionStatus.setComplete();
    return request.getParameter("next") == null ? "redirect:list"
            : "redirect:editQuestionSheet?surveyId=" + survey.getId();
}

From source file:org.jblogcms.core.blog.controller.AddBlogController.java

/**
 * Submits form for adding new blog//from  w  ww.ja v a  2 s .c om
 *
 * @param blogForm the new blog
 * @param result   the {@code BindingResult} object
 * @param status   the {@code SessionStatus} object
 * @param model    the {@code Model} object
 * @return logical String-based view name
 */
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/admin/blog/add", method = RequestMethod.POST)
public String addBlogSubmitForm(@Valid @ModelAttribute("blog") Blog blogForm, BindingResult result,
        SessionStatus status, Model model) {

    if (result.hasErrors()) {
        return "admin/blogAdd";
    } else {
        Long currentAccountId = securityService.getCurrentAccountId();

        Blog blog = addBlog(blogForm, currentAccountId, result);
        if (blog == null) {
            return "admin/blogAdd";
        }
        status.setComplete();

        return "redirect:/admin/blogs";
    }
}

From source file:org.openmrs.module.patientflags.web.EditTagController.java

/**
 * Processes the form to edit (or add) a Flag
 * /*from   ww  w .j  av  a2s  .c o m*/
 * @param flag the flag to add/update
 * @param result
 * @param status
 * @return new ModelAndView
 */
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processSubmit(@ModelAttribute("tag") Tag tag, BindingResult result, SessionStatus status) {

    // validate form entries
    validator.validate(tag, result);

    if (result.hasErrors()) {
        return new ModelAndView("/module/patientflags/editTag");
    }

    // add the new tag
    Context.getService(FlagService.class).saveTag(tag);

    // clears the command object from the session
    status.setComplete();

    // just display the edit page again
    return new ModelAndView("redirect:/module/patientflags/manageTags.list");
}

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

@RequestMapping(value = "/email/compose", params = "send")
public String compose(@ModelAttribute Email email, @RequestParam("userId") Long ids[],
        @RequestParam(value = "file", required = false) MultipartFile[] uploadedFiles,
        @RequestParam(value = "backUrl", required = false) String backUrl, BindingResult result,
        SessionStatus sessionStatus, ModelMap models) {
    email.setRecipients(userDao.getUsers(ids));
    emailValidator.validate(email, result);
    if (result.hasErrors())
        return "email/compose";

    User user = SecurityUtils.getUser();
    if (uploadedFiles != null)
        email.getAttachments().addAll(fileIO.save(uploadedFiles, user, true));

    emailUtils.sendTextMail(email);/*from  w w  w  . ja va2  s  . c  o m*/
    sessionStatus.setComplete();

    models.put("backUrl", backUrl);
    models.put("message", "status.email.sent");
    return "status";
}