Search in sources :

Example 36 with ModelAndView

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

the class LoanProductPreviewController method showPopulatedForm.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showPopulatedForm(@ModelAttribute("loanProduct") LoanProductFormBean loanProduct, @RequestParam(value = "editFormview", required = false) String editFormview) {
    ModelAndView modelAndView = new ModelAndView("previewLoanProducts");
    modelAndView.addObject("loanProduct", loanProduct);
    modelAndView.addObject("editFormview", editFormview);
    new ProductModelAndViewPopulator().populateModelAndViewForPreview(loanProduct, modelAndView);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 37 with ModelAndView

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

the class AdminDocumentController method postDocument.

@RequestMapping(value = "/updateAdminDoc", method = RequestMethod.POST)
public ModelAndView postDocument(@ModelAttribute AdminDocumentFormBean formBean, BindingResult result) {
    //        if( result.hasErrors()) {
    //            System.out.println("BindingResult has errors!");
    //        } else {
    //            System.out.println("No BindingResult errors!");
    //        }
    ModelAndView mav = new ModelAndView("updateAdminDoc");
    mav.addObject("formBean", formBean);
    return mav;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 38 with ModelAndView

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

the class AdminDocumentController method showDocument.

@RequestMapping(value = "/editAdminDocs", method = RequestMethod.GET)
public ModelAndView showDocument(HttpServletRequest request) {
    Integer id = Integer.parseInt(request.getParameter("id"));
    AdminDocumentDto document = findByDocId(id);
    /*
         * Since the DocumentDto is an immutable object. We would like to have
         *  a bean bound to the form that updates the document info. Basically don't want to
         *  change the DocumentDto object.
         *
         *  TODO: Need to understand where AdminDocumentFormBean gets all it's data
         *        Some of it comes from AdminDocumentDto, but not all variables.
         *
         *  Work In Progress.
         */
    ModelAndView mav = new ModelAndView("editAdminDocs");
    // Form Backed Object
    AdminDocumentFormBean formBean = new AdminDocumentFormBean();
    formBean.setAccountType("loan");
    formBean.setName(document.getName());
    formBean.setId(document.getId());
    Map<String, String> accountType = accountTypeMap();
    Map<String, String> showStatus = accountStatusMap(formBean.getAccountType());
    mav.addObject("status", showStatus);
    mav.addObject("accountType", accountType);
    mav.addObject("formBean", formBean);
    return mav;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) AdminDocumentDto(org.mifos.dto.domain.AdminDocumentDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 39 with ModelAndView

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

the class BatchjobsController method produceModelAndView.

private ModelAndView produceModelAndView(HttpServletRequest request, List<String> errorMessages) {
    ServletContext context = request.getSession().getServletContext();
    List<BatchjobsDto> batchjobs;
    BatchjobsSchedulerDto batchjobsScheduler;
    try {
        batchjobs = batchjobsServiceFacade.getBatchjobs(context);
    } catch (Exception tse) {
        errorMessages.add("Error when retrieving batch jobs information: " + tse.getMessage());
        batchjobs = new ArrayList<BatchjobsDto>();
    }
    try {
        batchjobsScheduler = batchjobsServiceFacade.getBatchjobsScheduler(context);
    } catch (Exception tse) {
        errorMessages.add("Error when retrieving batch jobs information: " + tse.getMessage());
        batchjobsScheduler = new BatchjobsSchedulerDto(false);
    }
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("request", request);
    model.put("batchjobs", batchjobs);
    if (batchjobsScheduler == null) {
        model.put("scheduler", "");
    } else {
        model.put("scheduler", batchjobsScheduler.isStatus());
    }
    model.put("date0", new Date(0));
    model.put("executedTasks", rawJobList);
    if (rawJobList.length > 0) {
        rawJobList = new String[0];
    }
    Map<String, Object> status = new HashMap<String, Object>();
    status.put("errorMessages", errorMessages);
    ModelAndView modelAndView = new ModelAndView("batchjobs", "model", model);
    modelAndView.addObject("status", status);
    return modelAndView;
}
Also used : HashMap(java.util.HashMap) BatchjobsSchedulerDto(org.mifos.application.admin.servicefacade.BatchjobsSchedulerDto) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) ServletContext(javax.servlet.ServletContext) BatchjobsDto(org.mifos.application.admin.servicefacade.BatchjobsDto) AccessDeniedException(org.springframework.security.access.AccessDeniedException) Date(java.util.Date)

Example 40 with ModelAndView

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

the class BatchjobsDetailsController method processFormSubmit.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView processFormSubmit(HttpServletRequest request) {
    Map<String, Object> model = new HashMap<String, Object>();
    List<String> errorMessages = new ArrayList<String>();
    ServletContext context = request.getSession().getServletContext();
    List<BatchjobsDto> batchjobs;
    try {
        batchjobs = batchjobsServiceFacade.getBatchjobs(context);
    } catch (Exception tse) {
        errorMessages.add("Error when retrieving batch jobs information: " + tse.getMessage());
        batchjobs = new ArrayList<BatchjobsDto>();
    }
    model.put("batchjobs", batchjobs);
    String[] jobFailNames = request.getParameterValues("jobFailName");
    if (jobFailNames != null && jobFailNames.length > 0) {
        model.put("jobFailName", jobFailNames[0]);
    } else {
        model.put("jobFailName", "");
    }
    Map<String, Object> status = new HashMap<String, Object>();
    status.put("errorMessages", errorMessages);
    ModelAndView modelAndView = new ModelAndView("batchjobsdetails", "model", model);
    modelAndView.addObject("status", status);
    return modelAndView;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) ServletContext(javax.servlet.ServletContext) BatchjobsDto(org.mifos.application.admin.servicefacade.BatchjobsDto) 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