Search in sources :

Example 21 with ModelAndView

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

the class EditOfficeInformationController method populateForm.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView populateForm(HttpServletRequest request) {
    ModelAndView modelAndView = new ModelAndView();
    Short officeId = officeServiceFacade.retrieveOfficeById(Short.parseShort(request.getParameter("officeLevelId"))).getLevelId();
    OfficeDto officeDto = officeServiceFacade.retrieveOfficeById(Short.parseShort(request.getParameter("officeLevelId")));
    OfficeFormBean formBean = new OfficeFormBean();
    if (officeDto.getAddress() != null) {
        formBean.setCity(officeDto.getAddress().getCity());
        formBean.setCountry(officeDto.getAddress().getCountry());
        formBean.setLine1(officeDto.getAddress().getLine1());
        formBean.setLine2(officeDto.getAddress().getLine2());
        formBean.setLine3(officeDto.getAddress().getLine3());
        formBean.setZip(officeDto.getAddress().getZip());
        formBean.setPhoneNumber(officeDto.getAddress().getPhoneNumber());
        formBean.setState(officeDto.getAddress().getState());
    }
    if (officeDto.getCustomFields() != null) {
        formBean.setCustomFields(officeDto.getCustomFields());
    }
    formBean.setGlobalNum(officeDto.getGlobalNum());
    formBean.setId(officeDto.getId());
    formBean.setLevelId(officeDto.getLevelId().toString());
    formBean.setLookupNameKey(officeDto.getLookupNameKey());
    formBean.setName(officeDto.getName());
    formBean.setOfficeLevelName(officeDto.getOfficeLevelName());
    formBean.setOfficeShortName(officeDto.getOfficeShortName());
    formBean.setOfficeStatusName(officeDto.getOfficeStatusName());
    if (officeDto.getLevelId() != 1) {
        formBean.setParentId(officeDto.getParentId().toString());
        formBean.setParentOfficeName(officeDto.getParentOfficeName());
    }
    formBean.setSearchId(officeDto.getSearchId());
    formBean.setStatusId(officeDto.getStatusId().toString());
    formBean.setVersionNum(officeDto.getVersionNum());
    modelAndView.addObject("officeFormBean", formBean);
    modelAndView.addObject("parentOffices", getParentDetails(officeId.toString()));
    modelAndView.addObject("view", "disable");
    modelAndView.addObject("officeTypes", getOfficeTypes(officeDto.getLevelId().toString()));
    modelAndView.addObject("showError", "false");
    return modelAndView;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 22 with ModelAndView

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

the class EditPenaltyController method showForm.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showForm(@RequestParam Integer penaltyId) {
    ModelAndView modelAndView = new ModelAndView("editPenalty");
    PenaltyDto dto = this.penaltyServiceFacade.getPenalty(penaltyId);
    parametersDto = this.penaltyServiceFacade.getPenaltyParameters();
    configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
    PenaltyFormBean bean = new PenaltyFormBean(dto);
    modelAndView.addObject("formBean", bean);
    modelAndView.addObject("param", parametersDto);
    modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
    return modelAndView;
}
Also used : PenaltyDto(org.mifos.dto.domain.PenaltyDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 23 with ModelAndView

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

the class EditProductCategoryController method processFormSubmit.

@edu.umd.cs.findbugs.annotations.SuppressWarnings
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") @Valid ProductCategoryFormBean formBean, BindingResult result) {
    ModelAndView modelAndView = new ModelAndView();
    if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName(REDIRECT_TO_ADMIN_SCREEN);
    } else if (result.hasErrors()) {
        modelAndView.setViewName("editCategoryInformation");
        modelAndView.addObject("formBean", formBean);
    } else {
        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 : ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 24 with ModelAndView

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

the class EditSavingsProductsFormController method processFormSubmit.

@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("savingsProduct") @Valid SavingsProductFormBean savingsProductFormBean, BindingResult result, SessionStatus status) {
    ModelAndView modelAndView = new ModelAndView("redirect:/previewSavingsProducts.ftl?editFormview=editSavingsProduct");
    configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
    modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
    if (StringUtils.isNotBlank(cancel)) {
        modelAndView.setViewName(REDIRECT_TO_ADMIN_SCREEN);
        status.setComplete();
    } else if (result.hasErrors()) {
        new SavingsProductValidator().validateGroup(savingsProductFormBean, result);
        modelAndView.setViewName("editSavingsProduct");
    } else {
        new SavingsProductValidator().validateGroup(savingsProductFormBean, result);
        if (result.hasErrors()) {
            modelAndView.setViewName("editSavingsProduct");
        }
    }
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 25 with ModelAndView

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

the class SavingsAccountController method showSavingsAccountDetails.

@RequestMapping(value = "/viewSavingsAccountDetails", method = RequestMethod.GET)
public ModelAndView showSavingsAccountDetails(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewSavingsAccountDetails", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String globalAccountNum = request.getParameter("globalAccountNum");
    SavingsAccountDetailDto savingsAccountDetailDto = savingsServiceFacade.retrieveSavingsAccountDetails(globalAccountNum);
    modelAndView.addObject("savingsAccountDetailDto", savingsAccountDetailDto);
    boolean containsQGForCloseSavings = false;
    containsQGForCloseSavings = questionnaireServiceFacade.getQuestionGroupInstances(savingsAccountDetailDto.getAccountId(), "Close", "Savings").size() > 0;
    modelAndView.addObject("containsQGForCloseSavings", containsQGForCloseSavings);
    modelAndView.addObject("backPageUrl", UrlHelper.constructCurrentPageUrl(request));
    savingsServiceFacade.putSavingsBusinessKeyInSession(globalAccountNum, request);
    // for mifostabletag
    request.getSession().setAttribute("recentActivityForDetailPage", savingsAccountDetailDto.getRecentActivity());
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) 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