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));
}
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));
}
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;
}
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;
}
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());
}
Aggregations