List of usage examples for org.springframework.web.servlet ModelAndView getModel
public Map<String, Object> getModel()
From source file:nl.surfnet.coin.selfservice.interceptor.AuthorityScopeInterceptorTest.java
@Test public void test_power_user_may_see_technical_mail_address() throws Exception { ModelAndView modelAndView = new ModelAndView(); CoinUser user = coinUser(ROLE_DASHBOARD_ADMIN); SecurityContextHolder.getContext()// ww w. j a v a2s . com .setAuthentication(new SAMLAuthenticationToken(user, "", user.getAuthorities())); Service sp = buildService(); modelAndView.addObject(BaseController.SERVICE, sp); interceptor.postHandle(new MockHttpServletRequest(), null, null, modelAndView); String technicalSupportMail = sp.getSupportMail(); assertNotNull(technicalSupportMail); // also allowed Map<String, Object> model = modelAndView.getModel(); assertTrue((Boolean) model.get(SERVICE_APPLY_ALLOWED)); }
From source file:gov.nih.nci.cabig.caaers.web.participant.SubjectMedHistoryTab.java
/** * Add an item to the collection through AJAX * *//*from ww w . java 2 s .c o m*/ public ModelAndView addPriorTherapy(HttpServletRequest request, Object cmd, Errors errors) { ParticipantInputCommand command = (ParticipantInputCommand) cmd; List<StudyParticipantPriorTherapy> priorTherapies = command.getAssignment().getPriorTherapies(); ModelAndView modelAndView = new ModelAndView("par/ajax/priorTherapyFormSection"); modelAndView.getModel().put("priorTherapies", priorTherapies); int size = priorTherapies.size(); Integer[] indexes = new Integer[] { size }; modelAndView.getModel().put("indexes", indexes); StudyParticipantPriorTherapy priorTherapy = new StudyParticipantPriorTherapy(); // priorTherapy.setPriorTherapy(command.getPriorTherapy()); priorTherapy.setStartDate(new DateValue()); priorTherapy.setEndDate(new DateValue()); priorTherapy.setPriorTherapyAgents(new ArrayList<StudyParticipantPriorTherapyAgent>()); command.getAssignment().addPriorTherapy(priorTherapy); // command.setPriorTherapy(null); command.getPriorTherapyAgents().add(null); //increment the element size return modelAndView; }
From source file:gov.nih.nci.cabig.caaers.web.participant.SubjectMedHistoryTab.java
/** * Add an item to the collection through AJAX * */// www . j av a2s .c o m public ModelAndView addPriorTherapyAgent(HttpServletRequest request, Object cmd, Errors errors) { ParticipantInputCommand command = (ParticipantInputCommand) cmd; StudyParticipantPriorTherapy priorTherapy = command.getAssignment().getPriorTherapies() .get(command.getParentIndex()); List<StudyParticipantPriorTherapyAgent> priorTherapyAgents = priorTherapy.getPriorTherapyAgents(); ModelAndView modelAndView = new ModelAndView("par/ajax/priorTherapyAgentFormSection"); modelAndView.getModel().put("priorTherapyAgents", priorTherapyAgents); modelAndView.getModel().put("parentIndex", command.getParentIndex()); int size = priorTherapyAgents.size(); Integer[] indexes = new Integer[] { size }; modelAndView.getModel().put("indexes", indexes); //NOTE : firefox for some reason is chopping off the '[x]' in the variable name, so had to do this goof-up in obtaining the chemoagent. StudyParticipantPriorTherapyAgent agent = new StudyParticipantPriorTherapyAgent(); // agent.setChemoAgent(command.getPriorTherapyAgent()); priorTherapy.addPriorTherapyAgent(agent); // u command.setPriorTherapyAgent( null); return modelAndView; }
From source file:gov.nih.nci.cabig.caaers.web.participant.SubjectMedHistoryTab.java
/** * Add an item to the collection through AJAX * *///w w w .ja v a 2 s.com public ModelAndView addPreExistingCondition(HttpServletRequest request, Object cmd, Errors errors) { ParticipantInputCommand command = (ParticipantInputCommand) cmd; List<StudyParticipantPreExistingCondition> preConditions = command.getAssignment() .getPreExistingConditions(); ModelAndView modelAndView = new ModelAndView("par/ajax/preExistingConditionFormSection"); modelAndView.getModel().put("preExistingConditions", preConditions); int size = preConditions.size(); Integer[] indexes = new Integer[] { size }; modelAndView.getModel().put("indexes", indexes); StudyParticipantPreExistingCondition preCondition = new StudyParticipantPreExistingCondition(); //preCondition.setPreExistingCondition(command.getPreExistingCondition()); command.getAssignment().addPreExistingCondition(preCondition); //command.setPreExistingCondition(null); return modelAndView; }
From source file:gov.nih.nci.cabig.caaers.web.participant.SubjectMedHistoryTab.java
/** * Remove an item from the collection through AJAX * *//* w w w . jav a 2 s . c om*/ public ModelAndView removePreExistingCondition(HttpServletRequest request, Object cmd, Errors errors) { ParticipantInputCommand command = (ParticipantInputCommand) cmd; List<StudyParticipantPreExistingCondition> preConditions = command.getAssignment() .getPreExistingConditions(); preConditions.remove(preConditions.get(command.getIndex())); //remove the element //create the indexes in reverse order int size = preConditions.size(); Integer[] indexes = new Integer[size]; for (int i = 0; i < size; i++) { indexes[i] = size - (i + 1); } ModelAndView modelAndView = new ModelAndView("par/ajax/preExistingConditionFormSection"); modelAndView.getModel().put("preExistingConditions", preConditions); modelAndView.getModel().put("indexes", indexes); return modelAndView; }
From source file:gov.nih.nci.cabig.caaers.web.participant.SubjectMedHistoryTab.java
/** * Remove an item from the collection through AJAX * *//* w ww . j a v a 2 s.co m*/ public ModelAndView removeConcomitantMedication(HttpServletRequest request, Object cmd, Errors errors) { ParticipantInputCommand command = (ParticipantInputCommand) cmd; List<StudyParticipantConcomitantMedication> conmeds = command.getAssignment().getConcomitantMedications(); conmeds.remove(conmeds.get(command.getIndex())); //remove the element //create the indexes in reverse order int size = conmeds.size(); Integer[] indexes = new Integer[size]; for (int i = 0; i < size; i++) { indexes[i] = size - (i + 1); } ModelAndView modelAndView = new ModelAndView("par/ajax/concomitantMedicationFormSection"); modelAndView.getModel().put("concomitantMedications", conmeds); modelAndView.getModel().put("indexes", indexes); return modelAndView; }
From source file:gov.nih.nci.cabig.caaers.web.participant.SubjectMedHistoryTab.java
/** * Remove an item from the collection through AJAX * */// ww w. jav a 2 s . com public ModelAndView removePriorTherapyAgent(HttpServletRequest request, Object cmd, Errors errors) { ParticipantInputCommand command = (ParticipantInputCommand) cmd; StudyParticipantPriorTherapy priorTherapy = command.getAssignment().getPriorTherapies() .get(command.getParentIndex()); List<StudyParticipantPriorTherapyAgent> priorTherapyAgents = priorTherapy.getPriorTherapyAgents(); priorTherapyAgents.remove(priorTherapyAgents.get(command.getIndex())); //remove the element //create the indexes in reverse order int size = priorTherapyAgents.size(); Integer[] indexes = new Integer[size]; for (int i = 0; i < size; i++) { indexes[i] = size - (i + 1); } ModelAndView modelAndView = new ModelAndView("par/ajax/priorTherapyAgentFormSection"); modelAndView.getModel().put("priorTherapyAgents", priorTherapyAgents); modelAndView.getModel().put("indexes", indexes); modelAndView.getModel().put("parentIndex", command.getParentIndex()); return modelAndView; }
From source file:gov.nih.nci.cabig.caaers.web.participant.SubjectMedHistoryTab.java
/** * Add an item to the collection through AJAX * *//*from ww w. ja va 2 s . com*/ public ModelAndView addConcomitantMedication(HttpServletRequest request, Object cmd, Errors errors) { ParticipantInputCommand command = (ParticipantInputCommand) cmd; List<StudyParticipantConcomitantMedication> conmeds = command.getAssignment().getConcomitantMedications(); ModelAndView modelAndView = new ModelAndView("par/ajax/concomitantMedicationFormSection"); modelAndView.getModel().put("concomitantMedications", conmeds); int size = conmeds.size(); Integer[] indexes = new Integer[] { size }; modelAndView.getModel().put("indexes", indexes); StudyParticipantConcomitantMedication conmed = new StudyParticipantConcomitantMedication(); conmed.setAgentName(command.getConcomitantMedication()); conmed.setStartDate(new DateValue()); conmed.setEndDate(new DateValue()); command.getAssignment().addConcomitantMedication(conmed); command.setConcomitantMedication(null); return modelAndView; }
From source file:gov.nih.nci.cabig.caaers.web.participant.SubjectMedHistoryTab.java
/** * Remoce all items from the collection/*w ww . j a va 2 s. c o m*/ * */ public ModelAndView removeAllPriorTherapyAgents(HttpServletRequest request, Object cmd, Errors errors) { ParticipantInputCommand command = (ParticipantInputCommand) cmd; StudyParticipantPriorTherapy priorTherapy = command.getAssignment().getPriorTherapies() .get(command.getParentIndex()); List<StudyParticipantPriorTherapyAgent> priorTherapyAgents = priorTherapy.getPriorTherapyAgents(); priorTherapyAgents.clear(); //create the indexes in reverse order int size = priorTherapyAgents.size(); Integer[] indexes = new Integer[size]; for (int i = 0; i < size; i++) { indexes[i] = size - (i + 1); } ModelAndView modelAndView = new ModelAndView("par/ajax/priorTherapyAgentFormSection"); modelAndView.getModel().put("priorTherapyAgents", priorTherapyAgents); modelAndView.getModel().put("indexes", indexes); modelAndView.getModel().put("parentIndex", command.getParentIndex()); return modelAndView; }
From source file:org.terasoluna.gfw.web.exception.SystemExceptionResolverTest.java
@Test public void testDoResolveException_super_return_notnull() throws Exception { // do setup.// w w w. j av a 2 s . c o m ResultMessages resultMessages = ResultMessages.error().add("code001"); BusinessException occurException = new BusinessException(resultMessages); // setup locale. Locale locale = Locale.ITALIAN; mockRequest.addPreferredLocale(locale); // setup FlashMap. FlashMap flashMap = new FlashMap(); mockRequest.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, flashMap); // setup exception resolver. // setup default. testTarget.setDefaultErrorView("defaultErrorView"); testTarget.setDefaultStatusCode(444); // setup exception code resolver. SimpleMappingExceptionCodeResolver exceptionCodeResolver = new SimpleMappingExceptionCodeResolver(); exceptionCodeResolver.setDefaultExceptionCode("defaultExceptionCode"); testTarget.setExceptionCodeResolver(exceptionCodeResolver); // do test. ModelAndView actualModleAndView = testTarget.doResolveException(mockRequest, mockResponse, null, occurException); // do assert. assertThat(mockResponse.getStatus(), is(444)); assertThat((Integer) mockRequest.getAttribute(WebUtils.ERROR_STATUS_CODE_ATTRIBUTE), is(444)); assertSame(occurException, actualModleAndView.getModel().get(SimpleMappingExceptionResolver.DEFAULT_EXCEPTION_ATTRIBUTE)); assertThat(mockRequest.getAttribute("exceptionCode").toString(), is("defaultExceptionCode")); assertThat(mockResponse.getHeader("X-Exception-Code"), is("defaultExceptionCode")); assertSame(resultMessages, flashMap.get(ResultMessages.DEFAULT_MESSAGES_ATTRIBUTE_NAME)); }