List of usage examples for org.springframework.ui ModelMap ModelMap
public ModelMap()
From source file:org.openmrs.module.pharm.web.controller.PharmTestPageController.java
/** * This class returns the form backing object. This can be a string, a * boolean, or a normal java pojo. The bean name defined in the * ModelAttribute annotation and the type can be just defined by the return * type of this method// w ww .ja v a 2 s . co m */ @ModelAttribute("data") protected ModelMap formBackingObject(HttpServletRequest request) throws Exception { ModelMap model = new ModelMap(); ArrayList<AdherenceRecordTmp> arts = new ArrayList<AdherenceRecordTmp>(); AdherenceRecordTmp art; for (int i = 1; i < 10; i++) { art = Context.getService(AdherenceRecordTmpService.class).getAdherenceRecordTmp(Integer.valueOf(i)); if (art != null) { arts.add(art); } } model.put("adherenceRecords", arts); model.put("message", "Hi buddy!"); model.put("pink", "Any colour you like!"); return model; }
From source file:org.esupportail.filex.web.WebController.java
@RequestMapping("VIEW") protected ModelAndView renderView(RenderRequest request, RenderResponse response) throws Exception { ModelMap model = new ModelMap(); final PortletPreferences prefs = request.getPreferences(); String eppnAttr = prefs.getValue(PREF_EPPN_ATTR, null); String restUrl = prefs.getValue(PREF_REST_URL, null); Map userInfos = (Map) request.getAttribute(PortletRequest.USER_INFO); String eppn = (String) userInfos.get(eppnAttr); log.info("Try to get FileX info for " + eppn); try {//w ww .j av a 2s . c o m MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>(); headers.add("eppn", eppn); HttpEntity<MultiValueMap<String, String>> httpRequest = new HttpEntity<MultiValueMap<String, String>>( null, headers); ResponseEntity<Filex> filexEntity = restTemplate.exchange(restUrl, HttpMethod.GET, httpRequest, Filex.class); log.debug("FileX info for " + eppn + " : " + filexEntity.getBody().toString()); model.put("filex", filexEntity.getBody()); } catch (HttpClientErrorException e) { return new ModelAndView("error", model); } model.put("serviceUrl", prefs.getValue(PREF_SERVICE_URL, null)); return new ModelAndView("view", model); }
From source file:org.jboss.arquillian.warp.extension.spring.container.provider.ErrorsProviderTestCase.java
/** * <p>Tests the {@link ErrorsProvider#canProvide(Class)} method when the provided resource is null.</p> *///w w w.j a v a 2s . com @Test public void testCanProvideResourceNull() { when(modelAndView.getModel()).thenReturn(new ModelMap()); assertFalse("The provider incorrectly handles null values.", instance.canProvide(Errors.class)); }
From source file:com.trenako.web.controllers.admin.AdminOptionsControllerTests.java
@Test public void shouldRenderNewOptionForms() { ModelMap model = new ModelMap(); String viewName = controller.newOption(model); assertEquals("option/new", viewName); assertTrue(model.containsAttribute("newForm")); }
From source file:game.kalaha.test.ModelControlTest.java
@Test public void testRetrieveStore() { ModelMap model = new ModelMap(); String functionReturn = controller.retrieveStore(0, model); assertEquals("Function return unexpected", "store_status", functionReturn); assertTrue("No stonecount in the model", model.containsKey("stonecount")); }
From source file:com.forexnepal.controller.HomeController.java
@RequestMapping(value = "/exchange_rates/bank/{bankId}", method = RequestMethod.GET) public @ResponseBody ModelMap ExchangeRatesByBank(@PathVariable(value = "bankId") int bankId) { ModelMap map = new ModelMap(); map.addAttribute("exchangeRatesByBank", exchangeRatesService.getByBank(bankId)); return map;/*from w w w .j a va2 s . c o m*/ }
From source file:com.microsoftopentechnologies.azchat.web.controllers.LoginController.java
/** * Render Index page./*from w w w. j av a 2s.co m*/ * * @return * @throws AzureChatException */ @RequestMapping(AzureChatConstants.FROM_PAGE_INDEX) public ModelAndView goIndex() throws AzureChatException { LOGGER.info("[LoginController][goLogin] start"); if (null != azureChatStartupUtils.getStartupErrors()) { return processResults(AzureChatConstants.VIEW_NAME_ERROR, new ModelMap(), azureChatStartupUtils.getStartupErrors()); } LOGGER.info("[LoginController][goLogin] end"); return new ModelAndView(AzureChatConstants.VIEW_NAME_INDEX); }
From source file:org.openmrs.web.controller.user.UserFormControllerTest.java
/** * @see UserFormController#handleSubmission(WebRequest,HttpSession,String,String,String,null, String, User,BindingResult) * *//* ww w. jav a 2 s . com*/ @Test @Verifies(value = "Creates Provider Account when Provider Account Checkbox is selected", method = "handleSubmission(WebRequest,HttpSession,String,String,String,null, String, User,BindingResult)") public void handleSubmission_createUserProviderAccountWhenProviderAccountCheckboxIsSelected() throws Exception { executeDataSet(TEST_DATA); WebRequest request = new ServletWebRequest(new MockHttpServletRequest()); //A user with userId=2 is preset in the Test DataSet and the relevant details are passed User user = Context.getUserService().getUser(2); Assert.assertTrue(Context.getProviderService().getProvidersByPerson(user.getPerson()).isEmpty()); ModelMap model = new ModelMap(); model.addAttribute("isProvider", false); controller.showForm(2, "true", user, model); controller.handleSubmission(request, new MockHttpSession(), new ModelMap(), "", null, "Test1234", "valid secret question", "valid secret answer", "Test1234", false, new String[] { "Provider" }, "true", "addToProviderTable", user, new BindException(user, "user")); Assert.assertFalse(Context.getProviderService().getProvidersByPerson(user.getPerson()).isEmpty()); }
From source file:fragment.web.AuthenticationControllerTest.java
@Before public void init() { map = new ModelMap(); session = new MockHttpSession(); asAnonymous(); }
From source file:org.esco.portlet.accueil.portlet.PortletController.java
@RequestMapping(value = { "VIEW" }, params = { "action=browseStandard" }) public ModelAndView browseStandard(RenderRequest request, RenderResponse response, final String view) { return new ModelAndView("view-portlet-" + view, new ModelMap()); }