Search in sources :

Example 26 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class SavingsAccountController method showSavingsAccountRecentActivity.

@RequestMapping(value = "/viewSavingsAccountRecentActivity", method = RequestMethod.GET)
public ModelAndView showSavingsAccountRecentActivity(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewSavingsAccountRecentActivity", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String globalAccountNum = request.getParameter("globalAccountNum");
    SavingsAccountDetailDto savingsAccountDetailDto = savingsServiceFacade.retrieveSavingsAccountDetails(globalAccountNum);
    modelAndView.addObject("savingsAccountDetailDto", savingsAccountDetailDto);
    modelAndView.addObject("currentDate", new Date());
    List<SavingsRecentActivityDto> recentActivity = this.savingsServiceFacade.retrieveRecentSavingsActivities(savingsAccountDetailDto.getAccountId().longValue());
    request.setAttribute("recentActivityList", recentActivity);
    savingsServiceFacade.putSavingsBusinessKeyInSession(globalAccountNum, request);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) SavingsRecentActivityDto(org.mifos.dto.screen.SavingsRecentActivityDto) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 27 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class SavingsProductController method showAllSavingsProducts.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showAllSavingsProducts() {
    ModelAndView modelAndView = new ModelAndView("viewSavingsProducts");
    List<ProductDisplayDto> productDto = adminServiceFacade.retrieveSavingsProducts();
    modelAndView.addObject("products", productDto);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) ProductDisplayDto(org.mifos.dto.screen.ProductDisplayDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 28 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class PreviewProductMixController method processFormSubmit.

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @RequestParam(value = "FORMVIEW", required = true) String formView, @ModelAttribute("formBean") ProductMixFormBean formBean, BindingResult result, SessionStatus status) {
    ModelAndView mav = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
    if (StringUtils.isNotBlank(edit)) {
        updateAllowedNotAllowedProductMix(formBean);
        resetAllowedAndNotAllowed(formBean);
        mav = new ModelAndView(formView);
        mav.addObject("formBean", formBean);
    } else if (StringUtils.isNotBlank(cancel)) {
        status.setComplete();
    } else if (result.hasErrors()) {
        mav = new ModelAndView("previewProductMix");
    } else {
        Integer productId = Integer.parseInt(formBean.getProductId());
        List<Integer> notAllowedProductIds = toIntegers(formBean.getNotAllowed());
        this.adminServiceFacade.createOrUpdateProductMix(productId, notAllowedProductIds);
        mav = new ModelAndView("confirmProductMix");
        mav.addObject("productId", productId);
    }
    return mav;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 29 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class ProductCategoryPreviewController method processFormSubmit.

@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") ProductCategoryFormBean formBean, BindingResult result) {
    String viewName = REDIRECT_TO_ADMIN_SCREEN;
    ModelAndView modelAndView = new ModelAndView();
    if (StringUtils.isNotBlank(edit)) {
        viewName = "editCategoryInformation";
        modelAndView.setViewName(viewName);
        modelAndView.addObject("formBean", formBean);
        modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder().withLink("admin.viewproductcategories", "viewProductCategories.ftl").withLink(formBean.getProductCategoryName(), "").build());
    } else if (StringUtils.isNotBlank(cancel)) {
        viewName = REDIRECT_TO_ADMIN_SCREEN;
        modelAndView.setViewName(viewName);
    } else if (result.hasErrors()) {
        viewName = "categoryPreview";
        modelAndView.setViewName(viewName);
        modelAndView.addObject("formBean", formBean);
        modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder().withLink("admin.viewproductcategories", "viewProductCategories.ftl").withLink(formBean.getProductCategoryName(), "").build());
    } else {
        Integer productStatusId = Integer.parseInt(formBean.getProductCategoryStatusId());
        Integer productTypeId = Integer.parseInt(formBean.getProductTypeId());
        CreateOrUpdateProductCategory productCategory = new CreateOrUpdateProductCategory(productTypeId.shortValue(), formBean.getProductCategoryName(), formBean.getProductCategoryDesc(), productStatusId.shortValue(), formBean.getGlobalPrdCategoryNum());
        try {
            this.adminServiceFacade.updateProductCategory(productCategory);
            modelAndView.setViewName(REDIRECT_TO_ADMIN_SCREEN);
        } catch (BusinessRuleException e) {
            ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: ");
            result.addError(error);
            modelAndView.setViewName("categoryPreview");
            modelAndView.addObject("formBean", formBean);
            modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder().withLink("admin.viewproductcategories", "viewProductCategories.ftl").withLink(formBean.getProductCategoryName(), "").build());
        }
    }
    return modelAndView;
}
Also used : CreateOrUpdateProductCategory(org.mifos.dto.domain.CreateOrUpdateProductCategory) BusinessRuleException(org.mifos.service.BusinessRuleException) ObjectError(org.springframework.validation.ObjectError) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 30 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class ReportsCategoryDefineController method processFormSubmit.

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("reportCategory") @Valid ReportCategoryFormBean reportCategory, BindingResult result, SessionStatus status) {
    ModelAndView modelAndView = new ModelAndView();
    if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName(REDIRECT_TO_ADMIN_SCREEN);
        status.setComplete();
    } else if (result.hasErrors()) {
        modelAndView.setViewName("defineReportCategory");
        modelAndView.addObject("reportCategory", reportCategory);
    } else {
        modelAndView.setViewName("redirect:/previewReportCategory.ftl");
        modelAndView.addObject("reportCategory", reportCategory);
    }
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ModelAndView (org.springframework.web.servlet.ModelAndView)1573 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)668 Test (org.junit.jupiter.api.Test)195 Test (org.junit.Test)188 HashMap (java.util.HashMap)165 ArrayList (java.util.ArrayList)139 RedirectView (org.springframework.web.servlet.view.RedirectView)90 Map (java.util.Map)84 List (java.util.List)69 IOException (java.io.IOException)60 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)60 Date (java.util.Date)57 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)49 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)49 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)47 GetMapping (org.springframework.web.bind.annotation.GetMapping)45 HandlerMethod (org.springframework.web.method.HandlerMethod)45 IPerson (org.apereo.portal.security.IPerson)43 JSONView (com.intel.mountwilson.util.JSONView)34