Search in sources :

Example 21 with ModelMap

use of org.springframework.ui.ModelMap in project gocd by gocd.

the class MyGoInterceptorTest method shouldPutSecurityIsDisbaledIntoModelAndView.

@Test
public void shouldPutSecurityIsDisbaledIntoModelAndView() throws Exception {
    securityIs(false);
    smtpIs(false);
    myGoInterceptor.postHandle(request, response, null, modelAndView);
    ModelMap modelMap = modelAndView.getModelMap();
    assertThat(modelMap.get(SECURITY_IS_ENABLED), is(false));
    assertThat(modelMap.get(SMTP_IS_ENABLED), is(false));
}
Also used : ModelMap(org.springframework.ui.ModelMap) Test(org.junit.Test)

Example 22 with ModelMap

use of org.springframework.ui.ModelMap in project gocd by gocd.

the class AuthorizationControllerTest method shouldSetModel.

@Test
public void shouldSetModel() throws Exception {
    ModelAndView responseModel = authorizationController.login(false, response);
    Map<String, Object> modelMap = new ModelMap() {

        {
            put("login_error", false);
            put("l", localizer);
            put("authentication_plugin_registry", authenticationPluginRegistry);
            put(GoVelocityView.CURRENT_GOCD_VERSION, CurrentGoCDVersion.getInstance());
        }
    };
    Map<String, Object> responseModelMap = responseModel.getModel();
    assertThat(responseModelMap, is(modelMap));
}
Also used : ModelMap(org.springframework.ui.ModelMap) ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Example 23 with ModelMap

use of org.springframework.ui.ModelMap in project OpenClinica by OpenClinica.

the class SDVController method viewAllSubjectFormHandler.

@RequestMapping("/viewAllSubjectSDVform")
public ModelMap viewAllSubjectFormHandler(HttpServletRequest request, HttpServletResponse response, @RequestParam("studyId") int studyId) {
    ModelMap gridMap = new ModelMap();
    StudyDAO studyDAO = new StudyDAO(dataSource);
    // StudyEventDAO studyEventDAO = new StudyEventDAO(dataSource);
    StudyBean studyBean = (StudyBean) studyDAO.findByPK(studyId);
    String pattern = "MM/dd/yyyy";
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    //  List<StudyEventBean> studyEventBeans = studyEventDAO.findAllByStudy(studyBean);
    //  List<EventCRFBean> eventCRFBeans = sdvUtil.getAllEventCRFs(studyEventBeans);
    //set up the parameters to take part in filtering
    ServletRequestDataBinder dataBinder = new ServletRequestDataBinder(new SdvFilterDataBean());
    dataBinder.setAllowedFields(new String[] { "study_subject_id", "studyEventDefinition", "studyEventStatus", "eventCRFStatus", "sdvRequirement", "eventcrfSDVStatus", "startUpdatedDate", "endDate", "eventCRFName" });
    dataBinder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(sdf, true));
    dataBinder.bind(request);
    BindingResult bindingResult = dataBinder.getBindingResult();
    //  eventCRFBeans = sdvUtil.filterEventCRFs(eventCRFBeans,bindingResult);
    //set up request attributes for sidebar
    //Not necessary when using old page design...
    // setUpSidebar(request);
    request.setAttribute("studyId", studyId);
    //We need a study subject id for the first tab; take it somewhat arbitrarily from the first study event bean
    /* int studySubjectId = 0;

        StudyEventBean studyBeanUrl = studyEventBeans.get(0);
        if(studyBeanUrl != null) {
            studySubjectId= studyBeanUrl.getStudySubjectId();
        }
        request.setAttribute("studySubjectId",studySubjectId);*/
    //set up the elements for the view's filter box
    /*sdvUtil.prepareSDVSelectElements(request,studyBean);*/
    ArrayList<String> pageMessages = (ArrayList<String>) request.getAttribute("pageMessages");
    if (pageMessages == null) {
        pageMessages = new ArrayList<String>();
    }
    request.setAttribute("pageMessages", pageMessages);
    String sdvMatrix = sdvUtil.renderEventCRFTableWithLimit(request, studyId, "");
    gridMap.addAttribute(SUBJECT_SDV_TABLE_ATTRIBUTE, sdvMatrix);
    return gridMap;
}
Also used : BindingResult(org.springframework.validation.BindingResult) CustomDateEditor(org.springframework.beans.propertyeditors.CustomDateEditor) ModelMap(org.springframework.ui.ModelMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ServletRequestDataBinder(org.springframework.web.bind.ServletRequestDataBinder) ArrayList(java.util.ArrayList) SdvFilterDataBean(org.akaza.openclinica.controller.helper.SdvFilterDataBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 24 with ModelMap

use of org.springframework.ui.ModelMap in project OpenClinica by OpenClinica.

the class UserController method userHandler.

/**
     * The method is mapped to the URL /user.htm
     * @param request  The HttpServletRequest for storing attributes.
     * @param userId   The id of the user.
     * @return The return value is a ModelMap (instead of ModelAndView object),
     * because the view name automatically resolves to "user"
     */
@RequestMapping("/user")
public ModelMap userHandler(HttpServletRequest request, @RequestParam("id") int userId) {
    ModelMap map = new ModelMap();
    List<String> userList = new ArrayList<String>();
    //set up request attributes for sidebar
    setUpSidebar(request);
    userList.add("Bruce");
    userList.add("Yufang");
    userList.add("Krikor");
    userList.add("Tom");
    //TODO: Get user from Hibernate DAO class
    //userList.add(userDao.loadUser(userId).getName())
    map.addAllAttributes(userList);
    return map;
}
Also used : ModelMap(org.springframework.ui.ModelMap) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 25 with ModelMap

use of org.springframework.ui.ModelMap in project gocd by gocd.

the class MyGoInterceptor method postHandle.

public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
    if (modelAndView == null) {
        return;
    }
    ModelMap data = modelAndView.getModelMap();
    data.put(SECURITY_IS_ENABLED, goConfigService.isSecurityEnabled());
    data.put(SMTP_IS_ENABLED, goConfigService.isSmtpEnabled());
}
Also used : ModelMap(org.springframework.ui.ModelMap)

Aggregations

ModelMap (org.springframework.ui.ModelMap)48 Test (org.junit.Test)23 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)18 ModelAndView (org.springframework.web.servlet.ModelAndView)11 RedirectAttributesModelMap (org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)5 Map (java.util.Map)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 IOException (java.io.IOException)3 Date (java.util.Date)3 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)3 HttpSessionRequiredException (org.springframework.web.HttpSessionRequiredException)3 RedirectAttributes (org.springframework.web.servlet.mvc.support.RedirectAttributes)3 NimbusClient (backtype.storm.utils.NimbusClient)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 HttpSession (javax.servlet.http.HttpSession)2