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.mifos.ui.core.controller.EditLoanProductFormController.java

@RequestMapping(method = RequestMethod.POST)
public String processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel,
        @ModelAttribute("loanProduct") @Valid LoanProductFormBean loanProductFormBean, BindingResult result,
        SessionStatus status) {

    String viewName = "redirect:/previewLoanProducts.ftl?editFormview=editLoanProduct";

    formBeanValidator.setValidator(validator);
    formBeanValidator.validate(loanProductFormBean, result);

    if (StringUtils.isNotBlank(cancel)) {
        viewName = REDIRECT_TO_ADMIN_SCREEN;
        status.setComplete();
    } else if (result.hasErrors()) {
        viewName = "editLoanProduct";
    }// www  . j  a v a  2s.  c o m

    return viewName;
}

From source file:org.mifos.ui.core.controller.EditPenaltyController.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView showPreview(@RequestParam(value = CANCEL_PARAM, required = false) String cancel,
        @ModelAttribute("formBean") @Valid PenaltyFormBean formBean, BindingResult result,
        SessionStatus status) {
    ModelAndView modelAndView = new ModelAndView(REDIRECT_TO_VIEW_PENALTY + formBean.getId());

    if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName(REDIRECT_TO_VIEW_PENALTY + formBean.getId());
        status.setComplete();
    } else {// w w  w . ja v a  2  s  . com
        if (result.hasErrors()) {
            parametersDto = this.penaltyServiceFacade.getPenaltyParameters();

            modelAndView.setViewName("editPenalty");
            modelAndView.addObject("param", parametersDto);
        } else {
            modelAndView.setViewName("penaltyPreview");

            modelAndView.addObject("period",
                    this.parametersDto.getPeriodType().get(formBean.getPeriodTypeId()));
            modelAndView.addObject("formula", this.parametersDto.getFormulaType().get(formBean.getFormulaId()));
            modelAndView.addObject("frequency",
                    this.parametersDto.getFrequencyType().get(formBean.getFrequencyId()));
            modelAndView.addObject("glCode", this.parametersDto.getGlCodes().get(formBean.getGlCodeId()));
            modelAndView.addObject("status", this.parametersDto.getStatusType().get(formBean.getStatusId()));
        }

        modelAndView.addObject("formBean", formBean);
    }

    return modelAndView;
}

From source file:org.mifos.ui.core.controller.EditPenaltyPreviewController.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit,
        @RequestParam(value = CANCEL_PARAM, required = false) String cancel, PenaltyFormBean formBean,
        BindingResult result, SessionStatus status) {
    ModelAndView modelAndView = new ModelAndView();

    if (StringUtils.isNotBlank(edit)) {
        modelAndView.setViewName("editPenalty");
        modelAndView.addObject("formBean", formBean);
        modelAndView.addObject("param", this.penaltyServiceFacade.getPenaltyParameters());
    } else if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName(REDIRECT_TO_VIEW_PENALTY + formBean.getId());
        status.setComplete();
    } else if (result.hasErrors()) {
        modelAndView.setViewName("penaltyPreview");
    } else {// www  .ja va 2 s .co  m
        modelAndView.setViewName(REDIRECT_TO_VIEW_PENALTY + formBean.getId());

        Short id = Short.valueOf(formBean.getId());
        Short categoryType = Short.valueOf(formBean.getCategoryTypeId());
        Short penaltyStatus = Short.valueOf(formBean.getStatusId());
        Short penaltyFrequency = Short.valueOf(formBean.getFrequencyId());
        Short glCode = Short.valueOf(formBean.getGlCodeId());
        boolean ratePenalty = StringUtils.isBlank(formBean.getAmount());
        Short currencyId = null;
        Double rate = null;
        Short penaltyFormula = null;
        Integer duration = null;
        Short penaltyPeriod = 3;

        if (ratePenalty) {
            rate = Double.valueOf(formBean.getRate());
            penaltyFormula = Short.valueOf(formBean.getFormulaId());
        }

        if (StringUtils.isNotBlank(formBean.getDuration())) {
            duration = Integer.valueOf(formBean.getDuration());
        }

        if (StringUtils.isNotBlank(formBean.getCurrencyId())) {
            currencyId = Short.valueOf(formBean.getCurrencyId());
        }

        if (StringUtils.isNotBlank(formBean.getPeriodTypeId())) {
            penaltyPeriod = Short.valueOf(formBean.getPeriodTypeId());
        }

        Double min = Double.valueOf(formBean.getMin());
        Double max = Double.valueOf(formBean.getMax());

        PenaltyFormDto dto = new PenaltyFormDto();
        dto.setId(id);
        dto.setCategoryType(categoryType);
        dto.setPenaltyStatus(penaltyStatus);
        dto.setPenaltyPeriod(penaltyPeriod);
        dto.setPenaltyFrequency(penaltyFrequency);
        dto.setGlCode(glCode);
        dto.setPenaltyFormula(penaltyFormula);
        dto.setPenaltyName(formBean.getName());
        dto.setRatePenalty(ratePenalty);
        dto.setCurrencyId(currencyId);
        dto.setRate(rate);
        dto.setAmount(formBean.getAmount());
        dto.setDuration(duration);
        dto.setMin(min);
        dto.setMax(max);

        this.penaltyServiceFacade.updatePenalty(dto);

        status.setComplete();
    }

    return modelAndView;
}

From source file:org.mifos.ui.core.controller.EditProductMixController.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel,
        @ModelAttribute("formBean") ProductMixFormBean formBean, BindingResult result, SessionStatus status) {

    ModelAndView mav = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);

    if (StringUtils.isNotBlank(cancel)) {
        status.setComplete();
    } else if (result.hasErrors()) {
        mav = new ModelAndView("editProductMix");
    } else {//from  w  ww  .jav a 2s  . c  om
        ProductMixPreviewDto preview = this.productMixAssembler.createProductMixPreview(formBean);

        mav = new ModelAndView("previewProductMix");
        mav.addObject("ref", preview);
        mav.addObject("formView", "editProductMix");
    }

    return mav;
}

From source file:org.mifos.ui.core.controller.EditSavingsProductsFormController.java

@RequestMapping(method = RequestMethod.POST)
public String processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel,
        @ModelAttribute("savingsProduct") @Valid SavingsProductFormBean savingsProductFormBean,
        BindingResult result, SessionStatus status) {

    String viewName = "redirect:/previewSavingsProducts.ftl?editFormview=editSavingsProduct";

    if (StringUtils.isNotBlank(cancel)) {
        viewName = REDIRECT_TO_ADMIN_SCREEN;
        status.setComplete();
    } else if (result.hasErrors()) {
        new SavingsProductValidator().validateGroup(savingsProductFormBean, result);
        viewName = "editSavingsProduct";
    } else {/*from  w  w  w.  ja  v a 2 s .c om*/
        new SavingsProductValidator().validateGroup(savingsProductFormBean, result);
        if (result.hasErrors()) {
            viewName = "editSavingsProduct";
        }
    }

    return viewName;
}

From source file:org.mifos.ui.core.controller.LatenessDormancyController.java

@RequestMapping(method = RequestMethod.POST)
public String processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel,
        @Valid @ModelAttribute("formBean") LatenessDormancyFormBean formBean, BindingResult result,
        SessionStatus status) {

    String viewName = REDIRECT_TO_ADMIN_SCREEN;

    if (StringUtils.isNotBlank(cancel)) {
        viewName = REDIRECT_TO_ADMIN_SCREEN;
        status.setComplete();
    } else if (result.hasErrors()) {
        viewName = "editLatenessDormancy";
    } else {//www.  j  a  va 2s .  co  m
        ProductConfigurationDto productConfigurationDto = new ProductConfigurationDto(
                formBean.getLatenessDays(), formBean.getDormancyDays());
        this.adminServiceFacade.updateProductConfiguration(productConfigurationDto);
        status.setComplete();
    }

    return viewName;
}

From source file:org.mifos.ui.core.controller.LoanProductPreviewController.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel,
        @RequestParam(value = EDIT_PARAM, required = false) String edit,
        @RequestParam(value = "editFormview", required = false) String editFormview,
        @ModelAttribute("loanProduct") LoanProductFormBean loanProduct, BindingResult result,
        SessionStatus status) {

    ModelAndView modelAndView = new ModelAndView(REDIRECT_TO_ADMIN);

    if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName(REDIRECT_TO_ADMIN);
        status.setComplete();
    } else if (StringUtils.isNotBlank(edit)) {
        modelAndView.setViewName(editFormview);
        modelAndView.addObject("loanProduct", loanProduct);

        loanProduct.resetMultiSelectListBoxes();
    } else if (result.hasErrors()) {
        modelAndView.setViewName("previewloanProducts");

        modelAndView.addObject("loanProduct", loanProduct);
        loanProduct.resetMultiSelectListBoxes();

        modelAndView.addObject("editFormview", editFormview);
        new ProductModelAndViewPopulator().populateModelAndViewForPreview(loanProduct, modelAndView);
    } else {//from   w  w  w .ja v a  2s  .com
        if ("defineLoanProducts".equals(editFormview)) {
            LoanProductRequest loanProductRequest = loanProductFormBeanAssembler.toLoanProductDto(loanProduct);
            PrdOfferingDto product = adminServiceFacade.createLoanProduct(loanProductRequest);
            modelAndView.setViewName("redirect:/confirmLoanProduct.ftl");
            modelAndView.addObject("product", product);
        } else {
            loanProduct.removeMultiSelectItems();
            LoanProductRequest loanProductRequest = loanProductFormBeanAssembler.toLoanProductDto(loanProduct);
            PrdOfferingDto product = adminServiceFacade.updateLoanProduct(loanProductRequest);
            modelAndView
                    .setViewName("redirect:/viewEditLoanProduct.ftl?productId=" + product.getPrdOfferingId());
            modelAndView.addObject("product", product);
        }
    }

    return modelAndView;
}

From source file:org.mifos.ui.core.controller.NewFundPreviewController.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit,
        @RequestParam(value = CANCEL_PARAM, required = false) String cancel,
        @ModelAttribute("formBean") FundFormBean formBean, BindingResult result, SessionStatus status) {

    ModelAndView mav = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);

    if (StringUtils.isNotBlank(edit)) {
        mav = new ModelAndView("editFunds");
        mav.addObject("formBean", formBean);
        mav.addObject("previewView", "newFundPreview");
    } else if (StringUtils.isNotBlank(cancel)) {
        mav = new ModelAndView(REDIRECT_TO_VIEW_FUNDS);
        status.setComplete();
    } else if (result.hasErrors()) {
        mav = new ModelAndView("newFundPreview");
    } else {//from   w  w  w. j ava 2s.  c o m
        FundCodeDto codeDto = new FundCodeDto();
        codeDto.setId(formBean.getCodeId());
        codeDto.setValue(formBean.getCodeValue());
        FundDto fundDto = new FundDto();
        fundDto.setCode(codeDto);
        fundDto.setId(formBean.getId());
        fundDto.setName(formBean.getName());
        this.fundServiceFacade.createFund(fundDto);
        status.setComplete();
    }
    return mav;
}

From source file:org.mifos.ui.core.controller.NewPenaltyPreviewController.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit,
        @RequestParam(value = CANCEL_PARAM, required = false) String cancel,
        @ModelAttribute("formBean") PenaltyFormBean formBean, BindingResult result, SessionStatus status) {

    ModelAndView modelAndView = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);

    if (StringUtils.isNotBlank(edit)) {
        modelAndView = new ModelAndView("defineNewPenalty");
        modelAndView.addObject("formBean", formBean);
        modelAndView.addObject("param", this.penaltyServiceFacade.getPenaltyParameters());
    } else if (StringUtils.isNotBlank(cancel)) {
        modelAndView = new ModelAndView(REDIRECT_TO_VIEW_PENALTIES);
        status.setComplete();
    } else if (result.hasErrors()) {
        modelAndView = new ModelAndView("newPenaltyPreview");
    } else {//from   ww  w.  jav  a2s. c  o m
        boolean ratePenalty = StringUtils.isBlank(formBean.getAmount());
        Short currencyId = null;
        Double rate = null;
        Short penaltyFormula = null;
        Short periodId = 3;
        Integer duration = null;

        if (ratePenalty) {
            rate = Double.valueOf(formBean.getRate());
            penaltyFormula = Short.valueOf(formBean.getFormulaId());
        }

        if (StringUtils.isNotBlank(formBean.getDuration())) {
            duration = Integer.valueOf(formBean.getDuration());
        }

        if (StringUtils.isNotBlank(formBean.getCurrencyId())) {
            currencyId = Short.valueOf(formBean.getCurrencyId());
        }

        if (StringUtils.isNotBlank(formBean.getPeriodTypeId())) {
            periodId = Short.valueOf(formBean.getPeriodTypeId());
        }

        PenaltyFormDto dto = new PenaltyFormDto();
        dto.setCategoryType(Short.valueOf(formBean.getCategoryTypeId()));
        dto.setPenaltyPeriod(periodId);
        dto.setPenaltyFrequency(Short.valueOf(formBean.getFrequencyId()));
        dto.setGlCode(Short.valueOf(formBean.getGlCodeId()));
        dto.setPenaltyFormula(penaltyFormula);
        dto.setPenaltyName(formBean.getName());
        dto.setRatePenalty(ratePenalty);
        dto.setCurrencyId(currencyId);
        dto.setRate(rate);
        dto.setAmount(formBean.getAmount());
        dto.setDuration(duration);
        dto.setMin(Double.valueOf(formBean.getMin()));
        dto.setMax(Double.valueOf(formBean.getMax()));

        this.penaltyServiceFacade.createPenalty(dto);

        status.setComplete();
    }
    return modelAndView;
}

From source file:org.mifos.ui.core.controller.PreviewHolidayController.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit,
        @RequestParam(value = CANCEL_PARAM, required = false) String cancel,
        @ModelAttribute("formBean") HolidayFormBean formBean, BindingResult result, SessionStatus status) {

    String viewName = REDIRECT_TO_ADMIN_SCREEN;

    ModelAndView modelAndView = new ModelAndView();
    if (StringUtils.isNotBlank(edit)) {
        viewName = "defineNewHoliday";
        modelAndView.setViewName(viewName);
        modelAndView.addObject("formBean", formBean);
    } else if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName("redirect:viewHolidays.ftl");
        status.setComplete();
    } else if (result.hasErrors()) {
        modelAndView.setViewName("previewHoliday");
    } else {//from w  w  w .ja  v  a  2 s . co  m

        HolidayDetails holidayDetail = holidayAssembler.translateHolidayFormBeanToDto(formBean);
        List<Short> branchIds = holidayAssembler.convertToIds(formBean.getSelectedOfficeIds());

        this.holidayServiceFacade.createHoliday(holidayDetail, branchIds);

        viewName = REDIRECT_TO_ADMIN_SCREEN;
        modelAndView.setViewName(viewName);
        status.setComplete();
    }
    return modelAndView;
}