Example usage for org.springframework.ui ModelMap ModelMap

List of usage examples for org.springframework.ui ModelMap ModelMap

Introduction

In this page you can find the example usage for org.springframework.ui ModelMap ModelMap.

Prototype

public ModelMap() 

Source Link

Document

Construct a new, empty ModelMap .

Usage

From source file:com.forexnepal.controller.HomeController.java

@RequestMapping(value = "/exchange_rates/all_dates", method = RequestMethod.GET)
public @ResponseBody ModelMap allForexDate() {
    ModelMap map = new ModelMap();

    map.addAttribute("forexDates", exchangeRatesService.getAllDate());
    return map;//  ww  w . j  a va  2  s . c  o m
}

From source file:id.go.kemdikbud.tandajasa.controller.PegawaiController.java

@RequestMapping("/pegawai/list")
public ModelMap daftarPegawai(@RequestParam(required = false) String search) {
    System.out.println("Daftar Pegawai");
    List<Pegawai> data = new ArrayList<Pegawai>();
    data.addAll(pegawaiDao.cariSemuaPegawai(search));

    ModelMap mm = new ModelMap();
    mm.addAttribute("daftarPegawai", data);
    return mm;//from  w w w.  j  av  a2 s.  co m
}

From source file:cz.muni.fi.mir.controllers.RevisionController.java

@RequestMapping(value = { "/create/", "/create" }, method = RequestMethod.GET)
@SiteTitle("{navigation.revision.create}")
public ModelAndView createRevision() {
    ModelMap mm = new ModelMap();
    mm.addAttribute("revisionForm", new RevisionForm());

    return new ModelAndView("revision_create", mm);
}

From source file:cz.muni.fi.mir.controllers.UserRoleController.java

@RequestMapping(value = { "/create", "/create/" }, method = RequestMethod.GET)
@SiteTitle("{navigation.userrole.create}")
public ModelAndView createUserRole() {
    ModelMap mm = new ModelMap();
    mm.addAttribute("userRoleForm", new UserRoleForm());

    return new ModelAndView("userrole_create", mm);
}

From source file:org.openmrs.web.patient.PatientDashboardGraphControllerTest.java

/**
 * Test getting a concept by name and by partial name.
 * /* www. ja va2 s  . co  m*/
 * @see PatientDashboardGraphController#showGraphData(Integer, Integer, ModelMap)
 */
@Test
@Verifies(value = "return json data with observation details and critical values for the concept", method = "showGraphData(Integer, Integer, ModelMap)")
public void shouldReturnJSONWithPatientObservationDetails() throws Exception {
    executeDataSet("org/openmrs/api/include/ObsServiceTest-initial.xml");
    PatientDashboardGraphController controller = new PatientDashboardGraphController();

    long firstObsDate = new GregorianCalendar(2006, Calendar.FEBRUARY, 9).getTimeInMillis();
    long secondObsDate = new GregorianCalendar(2006, Calendar.FEBRUARY, 10).getTimeInMillis();

    ModelMap map = new ModelMap();
    controller.showGraphData(2, 1, map);
    PatientGraphData graph = (PatientGraphData) map.get("graph");

    String expectedData = String.format(
            "{\"absolute\":{\"high\":50.0,\"low\":2.0},\"critical\":{\"high\":null,\"low\":null},\"name\":\"Some concept name\",\"normal\":{\"high\":null,\"low\":null},\"data\":[[%d,null],[%d,1.0]],\"units\":\"\"}",
            secondObsDate, firstObsDate);

    ObjectMapper mapper = new ObjectMapper();
    JsonNode expectedJson = mapper.readTree(expectedData);
    JsonNode actualJson = mapper.readTree(graph.toString());

    Assert.assertEquals(expectedJson.size(), actualJson.size());
    for (Iterator<String> fieldNames = expectedJson.getFieldNames(); fieldNames.hasNext();) {
        String field = fieldNames.next();
        Assert.assertEquals(expectedJson.get(field), actualJson.get(field));
    }
}

From source file:cz.muni.fi.mir.controllers.SourceDocumentController.java

@RequestMapping(value = { "/create", "/create/" }, method = RequestMethod.GET)
@SiteTitle("{navigation.sourcedocument.create}")
public ModelAndView create() {
    ModelMap mm = new ModelMap();
    mm.addAttribute("sourceDocumentForm", new SourceDocumentForm());

    return new ModelAndView("sourcedocument_create", mm);
}

From source file:com.trenako.web.controllers.CommentsControllerTests.java

@Test
public void shouldPostNewComments() {
    String slug = "acme-123456";
    ModelMap model = new ModelMap();

    when(mockResult.hasErrors()).thenReturn(false);
    when(mockRsService.findBySlug(eq(slug))).thenReturn(rollingStock());

    controller.setTimestamp(date("2012/08/01"));
    String redirect = controller.postComment(commentForm(), mockResult, model, mockRedirectAtts);

    assertEquals("redirect:/rollingstocks/{slug}", redirect);
    verify(mockService, times(1)).postComment(eq(rollingStock()), eq(comment()));
    verify(mockRedirectAtts, times(1)).addFlashAttribute(eq("message"),
            eq(CommentsController.COMMENT_POSTED_MSG));
}

From source file:org.cloudfoundry.identity.uaa.oauth.AccessControllerTests.java

@Test
public void testSunnyDay() throws Exception {
    InMemoryClientDetailsService clientDetailsService = new InMemoryClientDetailsService();
    clientDetailsService.setClientDetailsStore(Collections.singletonMap("client", new BaseClientDetails()));
    controller.setClientDetailsService(clientDetailsService);
    controller.setApprovalStore(Mockito.mock(ApprovalStore.class));
    Authentication auth = UaaAuthenticationTestFactory.getAuthentication("foo@bar.com", "Foo Bar",
            "foo@bar.com");
    String result = controller.confirm(new ModelMap(), new MockHttpServletRequest(), auth,
            new SimpleSessionStatus());
    assertEquals("access_confirmation", result);
}

From source file:cz.muni.fi.mir.controllers.ConfigurationController.java

@RequestMapping(value = { "/create", "/create/" }, method = RequestMethod.GET)
@SiteTitle("{entity.configuration.create}")
public ModelAndView createConfiguration() {
    ModelMap mm = new ModelMap();
    mm.addAttribute("configurationForm", new ConfigurationForm());

    return new ModelAndView("configuration_create", mm);
}

From source file:org.openmrs.module.formfilter.web.controller.AddFormFilterPropertyControllerTest.java

/**
 * @see {@link AddFormFilterPropertyController#addFormFilter(ModelMap, Integer, int)}
 *//* w  w  w.ja  v a  2  s  . co  m*/
@Test
@Verifies(value = "should support add new filter functionality", method = "addFormFilter(ModelMap,Integer,int)")
public void addFormFilter_shouldSupportAddNewFilterFunctionality() {

    AddFormFilterPropertyController controller = new AddFormFilterPropertyController();
    ModelMap model = new ModelMap();
    controller.addFormFilter(model, 1, null);
    Assert.assertNotNull(((FormFilter) model.get("formFilter")));
    Assert.assertNull(((FormFilterProperty) model.get("formFilterProperty")).getFilterName());
}