Search in sources :

Example 31 with ModelAndView

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

the class ReportsCategoryDeleteController method processFormSubmit.

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

Example 32 with ModelAndView

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

the class SystemInformationController method viewSystemInformation.

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_UNWRITTEN_FIELD", justification = "request is not null")
@RequestMapping(method = RequestMethod.GET)
public ModelAndView viewSystemInformation(HttpServletRequest request) {
    ServletContext context = request.getSession().getServletContext();
    RequestContext requestContext = new RequestContext(request);
    Locale locale = requestContext.getLocale();
    SystemInformationDto systemInformationDto = systemInformationServiceFacade.getSystemInformation(context, locale);
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("request", request);
    model.put("systemInformationDto", systemInformationDto);
    Map<String, Object> status = new HashMap<String, Object>();
    List<String> errorMessages = new ArrayList<String>();
    status.put("errorMessages", errorMessages);
    ModelAndView modelAndView = new ModelAndView("systemInformation", "model", model);
    modelAndView.addObject("status", status);
    return modelAndView;
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) ServletContext(javax.servlet.ServletContext) RequestContext(org.springframework.web.servlet.support.RequestContext) SystemInformationDto(org.mifos.application.admin.servicefacade.SystemInformationDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 33 with ModelAndView

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

the class GenericController method handleRequestInternal.

@Override
@RequestMapping(value = { "/accessDenied.ftl", "/pageNotFound.ftl", "/ping.ftl", "/cheetah.css.ftl", "/gazelle.css.ftl", "/adminHome.ftl", "/maincss.css", "/screen.css", "/maincss.css.ftl", "/screen.css.ftl", "/admin.ftl", "/defineLookupOptions.ftl", "/viewChecklists.ftl", "/viewEditCheckLists.ftl", "/viewAdditionalFields.ftl", "/viewReportsTemplates.ftl", "/defineAdditionalFields.ftl", "/defineNewChecklist.ftl", "/redoLoansDisbursal.ftl", "/editAdditionalFields.ftl", "/previewChecklist.ftl", "confirmProductMix.ftl", "confirmSavingsProduct.ftl", "confirmLoanProduct.ftl" })
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("request", request);
    Map<String, Object> status = new HashMap<String, Object>();
    List<String> errorMessages = new ArrayList<String>();
    status.put("errorMessages", errorMessages);
    ModelAndView modelAndView = new ModelAndView(getPageToDisplay(request), "model", model);
    modelAndView.addObject("status", status);
    return modelAndView;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 34 with ModelAndView

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

the class HomePageController method showPopulatedForm.

@RequestMapping(method = RequestMethod.GET)
@ModelAttribute("customerSearch")
public ModelAndView showPopulatedForm(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("customerSearch") CustomerSearchFormBean customerSearchFormBean) throws MifosException, PersistenceException {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "home", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    Short userId = (short) user.getUserId();
    UserDetailDto userDetails = this.centerServiceFacade.retrieveUsersDetails(userId);
    modelAndView.addObject("customerSearch", customerSearchFormBean);
    boolean isCenterHierarchyExists = configurationServiceFacade.getBooleanConfig("ClientRules.CenterHierarchyExists");
    modelAndView.addObject("isCenterHierarchyExists", isCenterHierarchyExists);
    if (sitePreferenceHelper.isMobile(request)) {
        List<ValueListElement> availibleClientGenders = clientServiceFacade.getClientGenders();
        modelAndView.addObject("availibleClientGenders", availibleClientGenders);
        HashMap<String, ArrayList<CustomerStatusDetailDto>> customerStates = new HashMap<String, ArrayList<CustomerStatusDetailDto>>();
        customerStates.putAll(customerSearchServiceFacade.getAvailibleCustomerStates());
        modelAndView.addObject("availibleCustomerStates", customerStates);
    }
    if (userDetails.isLoanOfficer()) {
        loadLoanOfficerCustomersHierarchyForSelectedDay(userId, modelAndView, customerSearchFormBean);
        modelAndView.addObject("isLoanOfficer", true);
    } else {
        modelAndView.addObject("isLoanOfficer", false);
    }
    return modelAndView;
}
Also used : CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) UserDetailDto(org.mifos.dto.domain.UserDetailDto) IncludePage(freemarker.ext.servlet.IncludePage) ValueListElement(org.mifos.dto.domain.ValueListElement) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 35 with ModelAndView

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

the class InitializeApplicationController method handleRequestInternal.

@RequestMapping("/initializeApplication.ftl")
// Reason: here we want to surface a generic exception
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView returnValue = new ModelAndView("pageNotFound");
    if (TestMode.MAIN == getTestingService().getTestMode()) {
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    } else {
        getTestingService().reinitializeCaches();
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("request", request);
        Map<String, Object> status = new HashMap<String, Object>();
        List<String> errorMessages = new ArrayList<String>();
        status.put("errorMessages", errorMessages);
        ModelAndView modelAndView = new ModelAndView("initializeApplication", "model", model);
        modelAndView.addObject("status", status);
        returnValue = modelAndView;
    }
    return returnValue;
}
Also used : HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) 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